-
Bug
-
Resolution: Fixed
-
P3
-
6u22
-
b01
-
x86
-
linux
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2210448 | 8 | Maurizio Cimadamore | P3 | Closed | Fixed | b08 |
JDK-2212863 | 7u4 | Dmeetry Degrave | P3 | Closed | Fixed | b07 |
FULL PRODUCT VERSION :
1.6.0_22-b04 and 1.7.0-ea-b119
A DESCRIPTION OF THE PROBLEM :
Compiling and running a class with a local class that is only used via a subclass causes an IncompatibleClassChangeError. See the attached example.
It could be either a jvm or a compiler bug.
I suspect it is a compiler bug because it works with the Eclipse compiler, and adding a dummy reference to the class fixes it. My guess is that the compiler forgets to add an entry in the InnerClasses attribute because it doesn't notice that the class is being referenced.
The problem does not occur when running with a Java 5 jvm (compiled with 5,6 or 7-ea compiler), but that might be because that version doesn't check the InnerClasses attribute (or is less strict).
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.IncompatibleClassChangeError: LocalClassTest and LocalClassTest$1A disagree on InnerClasses attribute
at java.lang.Class.getDeclaringClass(Native Method)
at LocalClassTest.main(LocalClassTest.java:5)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class LocalClassTest {
public static void main(String... args) {
class A {}
class B extends A {}
B.class.getSuperclass().getDeclaringClass();
// using A directly anywhere works around the problem:
// new A();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Add a reference to the local class, e.g. the dummy "new A()" in the example.
1.6.0_22-b04 and 1.7.0-ea-b119
A DESCRIPTION OF THE PROBLEM :
Compiling and running a class with a local class that is only used via a subclass causes an IncompatibleClassChangeError. See the attached example.
It could be either a jvm or a compiler bug.
I suspect it is a compiler bug because it works with the Eclipse compiler, and adding a dummy reference to the class fixes it. My guess is that the compiler forgets to add an entry in the InnerClasses attribute because it doesn't notice that the class is being referenced.
The problem does not occur when running with a Java 5 jvm (compiled with 5,6 or 7-ea compiler), but that might be because that version doesn't check the InnerClasses attribute (or is less strict).
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.IncompatibleClassChangeError: LocalClassTest and LocalClassTest$1A disagree on InnerClasses attribute
at java.lang.Class.getDeclaringClass(Native Method)
at LocalClassTest.main(LocalClassTest.java:5)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class LocalClassTest {
public static void main(String... args) {
class A {}
class B extends A {}
B.class.getSuperclass().getDeclaringClass();
// using A directly anywhere works around the problem:
// new A();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Add a reference to the local class, e.g. the dummy "new A()" in the example.
- backported by
-
JDK-2210448 IncompatibleClassChangeError with unreferenced local class with subclass
-
- Closed
-
-
JDK-2212863 IncompatibleClassChangeError with unreferenced local class with subclass
-
- Closed
-
- relates to
-
JDK-6814659 separable cleanups and subroutines for 6655638
-
- Resolved
-