United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7003595 IncompatibleClassChangeError with unreferenced local class with subclass
JDK-7003595 : IncompatibleClassChangeError with unreferenced local class with subclass

Details
Type:
Bug
Submit Date:
2010-11-30
Status:
Closed
Updated Date:
2012-10-01
Project Name:
JDK
Resolved Date:
2012-02-02
Component:
tools
OS:
linux
Sub-Component:
javac
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u22
Fixed Versions:
6u32 (b01)

Related Reports
Backport:
Backport:
Relates:

Sub Tasks

Description
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.

                                    

Comments
EVALUATION

2009-03-24-164453.never.6805522 wasn't going to hotspot-comp which is why it passed.

JPRT Job ID:            2009-03-24-164453.never.6805522
JPRT System Used:       hotspotwest
JPRT Version Used:      1.1: (2009-03-09) Case of the Dubious Bridegroom
 [49091064964c]
Job URL:
 http://prt-web.sfbay.sun.com/archive/2009/03/2009-03-24-164453.never.6805522
Job ARCHIVE:
 /net/prt-archiver.sfbay.sun.com/data/jprt/archive/2009/03/2009-03-24-164453.never.6805522
User:                   never
Email:                  ###@###.###
Release:                jdk7
Job Source:             Mercurial: /net/smite.sfbay/export/ws/6u14/{.}
Parent:                 /net/jano2/export2/hotspot/ws/14/baseline
Push Parent:            /net/jano2/export2/hotspot/ws/14/baseline
CR List:                6805522

This is the sequence of real successful pushes:

2009-03-24-192443.cf231476.6636138
2009-03-23-210320.never.6805522
2009-03-21-062220.jrose.hs-6814659
2009-03-19-163209.kvn.hs-comp-merg

and it started failing with john's push.

Unpacking 2009-03-24-192443.cf231476.6636138 ...
unzip -oq /net/prt-archiver.us.oracle.com/data/jprt/archive/2009/03/2009-03-24-192443.cf231476.6636138/bundles/solaris_i586_5.10-fastdebug.zip jre/lib/i386/server/libjvm.so
Running 2009-03-24-192443.cf231476.6636138
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b51)
OpenJDK Server VM (build 15.0-b03-2009-03-24-192443.cf231476.6636138-fastdebug, mixed mode)

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)
Unpacking 2009-03-23-210320.never.6805522 ...
unzip -oq /net/prt-archiver.us.oracle.com/data/jprt/archive/2009/03/2009-03-23-210320.never.6805522/bundles/solaris_i586_5.10-fastdebug.zip jre/lib/i386/server/libjvm.so
Running 2009-03-23-210320.never.6805522
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b51)
OpenJDK Server VM (build 15.0-b03-2009-03-23-210320.never.6805522-fastdebug, mixed mode)

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)
Unpacking 2009-03-21-062220.jrose.hs-6814659 ...
unzip -oq /net/prt-archiver.us.oracle.com/data/jprt/archive/2009/03/2009-03-21-062220.jrose.hs-6814659/bundles/solaris_i586_5.10-fastdebug.zip jre/lib/i386/server/libjvm.so
Running 2009-03-21-062220.jrose.hs-6814659
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b51)
OpenJDK Server VM (build 15.0-b03-2009-03-21-062220.jrose.hs-6814659-fastdebug, mixed mode)

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)
Unpacking 2009-03-19-163209.kvn.hs-comp-merge ...
unzip -oq /net/prt-archiver.us.oracle.com/data/jprt/archive/2009/03/2009-03-19-163209.kvn.hs-comp-merge/bundles/solaris_i586_5.10-fastdebug.zip jre/lib/i386/server/libjvm.so
Running 2009-03-19-163209.kvn.hs-comp-merge
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b51)
Java HotSpot(TM) Server VM (build 15.0-b03-2009-03-19-163209.kvn.hs-comp-merge-fastdebug, mixed mode)

It's not obvious to me what John changed to break this but I think it's finding the class in a situation where it previously wouldn't so it will skip the check_for_inner_class call.
                                     
2011-08-30



Hardware and Software, Engineered to Work Together