JDK-6547131 : java.lang.ClassFormatError when using old collection API
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6u1
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-04-17
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u2Fixed 7 b14Fixed
Related Reports
Relates :  
Relates :  
Description
This seems to be an incompatibility issue between JDK50 and JDK60.

On JDK5, the attached test.java works fine but JDK6 gives the following error. (the test.java needs to be compiled and run with the attached collections.zip in CLASSPATH.)


Exception in thread "main" java.lang.ClassFormatError: Illegal class modifiers i
n class test: 0x209
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

Comments
SUGGESTED FIX Webrev: http://sa.sfbay.sun.com/projects/langtools_data/7/6547131/
16-08-2007

EVALUATION This doesn't relate to the StackMapTable attribute. For compatibility reason, the VM only checks newly added rules in JDK 6 for class files with version >=50. Therefore the error only occurs in target 6. This regression is caused by the fix of 4012001, in which the VM enforces all interfaces to be abstract for class files with version >=50. Although javac ensures that the interfaces it generates are abstract, it doesn't do so for the inner classes it reads from other sources. In this case, the inner class Enter is read from the old collection archive, which doesn't have its "abstract" flag set.
26-04-2007

SUGGESTED FIX javac will set the "abstract" flag for all the interfaces in InnerClasses attribute.
26-04-2007

EVALUATION I can reproduce the problem. When I run JDK 6.0 javac with -target 5 option, the problem goes away. This indicates that this is either a problem in how the compiler generates the new StackMapTable attribute or how the VM handles it. The compiler team will investigate further.
25-04-2007

WORK AROUND Use -target 5 when compiling.
25-04-2007