United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6547131 java.lang.ClassFormatError when using old collection API
6547131 : java.lang.ClassFormatError when using old collection API

Details
Type:
Bug
Submit Date:
2007-04-17
Status:
Closed
Updated Date:
2011-03-08
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
tools
OS:
generic
Sub-Component:
javac
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u1
Fixed Versions:
7

Related Reports
Backport:
Relates:
Relates:

Sub Tasks

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/
                                     
2007-08-16
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.
                                     
2007-04-26
SUGGESTED FIX

javac will set the "abstract" flag for all the interfaces in InnerClasses attribute.
                                     
2007-04-26
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.
                                     
2007-04-25
WORK AROUND

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



Hardware and Software, Engineered to Work Together