| Summary: | LinkageError caused by duplicate loadclass calls for the same class on the same ClassLoader | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Equinox | Reporter: | Kevan Miller <kevan.miller> | ||||||||
| Component: | Framework | Assignee: | Thomas Watson <tjwatson> | ||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | dj.houghton | ||||||||
| Version: | 3.6 | Flags: | dj.houghton:
review+
|
||||||||
| Target Milestone: | 3.7 RC1 | ||||||||||
| Hardware: | Macintosh | ||||||||||
| OS: | Mac OS X - Carbon (unsup.) | ||||||||||
| Whiteboard: | |||||||||||
| Attachments: |
|
||||||||||
|
Description
Kevan Miller
Created attachment 195437 [details]
patch
This patch will detect recursive calls to defineClass for the same class name and will instead cause a ClassNotFoundException to be thrown. This will avoid the LinkageError. This helps in the Geronimo case because the scenario involves a class transformation during defineClass which then causes another class loader to be used to try and load the same class and that eventually delegates to the same class loader which is trying to define the class.
Apparently the inner defineClass succeeds! But then the outer one which initiated the whole thing failes with a LinkageError. This transformation code can handle the CNFE, but there is nothing it can do about a LinkageError being thrown from the initiating defineClass.
Purely from the frameworks perspective, I am not sure if a CNFE exception is better than a LinkageError. But I think it would be good to get consistent behavior between Felix and Equinox on this.
Created attachment 195440 [details]
new patch
Tom and I talked this over and here is a slightly modified patch.
Patch released. Created attachment 195448 [details]
stacktrace of the problem
Thanks! That looks like the patch should do the trick.
For historical documentation I've attached the stacktrace of the problem.
The ClassLoader.defineClass() call on line 4 of the file (your "inner" call) will succeed.
However, when the call stack unwinds to the ClassLoader.defineClass1(Native Method), on line 38 of the file (your "outer" call, that defineClass1() invocation will throw a LinkageError.
ClassLoader instances are the same on line 4 and 38. And both are defining the same class.
Throwing CNFE or LinkageError from the "inner" call will work -- we have code for either case. Consistency sounds good to me.
Many thanks for the quick solution.
|