United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4972409 cryptic error message: LinkageError [classname] violates loader constraints
JDK-4972409 : cryptic error message: LinkageError [classname] violates loader constraints

Details
Type:
Enhancement
Submit Date:
2003-12-24
Status:
Closed
Updated Date:
2012-10-13
Project Name:
JDK
Resolved Date:
2006-07-29
Component:
hotspot
OS:
windows_xp
Sub-Component:
runtime
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.2
Fixed Versions:

Related Reports
Relates:
Relates:

Sub Tasks

Description
When two classes of the same name are loaded inconsistently, the VM issues the above LinkageError, but the error message is very cryptic.

At the very least it can refer to the VM spec section 5.3.4. Furthermore, it should provide more information (such as (a) which class loader tried to load the 2nd class, (b) which class loader loaded the original definition, (c) where those two classes are being loaded from.)
Also, if I'm not mistaken, the error message could be further improved to indicate exactly which
constraint is violated.

All of those information makes it easier for developers to track down the problem. If you search
Google with "LinkageError loader constraints", you'll see how developers out there are hopelessly
confused with this error.

Finally, the definition of the loader constraints in the VM spec is hard to understand for most of the people. Perhaps it could be clarified in somewhere?

###@###.### 2003-12-23

                                    

Comments
EVALUATION

Providing more information in the error messages
will require some code reorganization as the error
string is currently a simple const char* which is
passed back to a calling routine -- the calling
routine throws the LinkageError.

We'll need to malloc a string and arrange to free
it if the error needs to be thrown.

Also, we'll need to record some more information
to be more specific in the message.

I'll commit this bug to 1.5.1;  we're too late in
the 1.5.0 development cycle to consider for this
release. However, I will update the current static
strings in the error messages to refer to the VM
spec section.

###@###.### 2004-01-21
                                     
2004-01-21
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
dragon


                                     
2004-09-08
EVALUATION

All the information that the requestor asks for is not readily available at the time that a constraint is violated, but we can at least provide information in the error message as to the general context in which the violation was detected, and the class loaders involved (though only by type as classloaders are not named and so different instances can't be distinguished. For example:

java.lang.LinkageError: loader constraint violation: in resolving method "B.getA()LA;" the class loader (instance of sun/misc/Launcher$AppClassLoader) of the current class, C, and the class loader (instance of Loader) for interface I have different Class objects for the type A used in the signature

We are also looking at providing additional diagnostic "trace messages" to show when loader constraints are added, extended or removed. Together these will allow the developer to more easily track down class loading problems.
                                     
2006-06-14
EVALUATION

Note that there are now 6 different circumstances where loader constraint violations are identified:

1. Resolving the types in a method
2. Resolving the types in an interface method
3. Resolving the types in an overriding method
4. Resolving the types in a method during interface itable initialization
5. Resolving a field
6. The loader has previously initiated loading for a different type with the same name
                                     
2006-07-19



Hardware and Software, Engineered to Work Together