JDK-6553734 : package-info class compiled on JDK 6 target 1.5 cannot be loaded by JDK 5
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: generic
  • CPU: generic
  • Submitted: 2007-05-04
  • Updated: 2011-01-27
  • Resolved: 2009-05-26
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.
Other Other
5.0-poolResolved 5.0u13Resolved
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
A package-info class contains annotated package and annotation type. These classes are compiled using JDK 6 compiler with target 1.5. JDK 5 fails to load the generated package-info with the following error:

Exception in thread "main" java.lang.ClassFormatError: Illegal class modifiers in class pack/package-info: 0x1600
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$100(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:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:242)
        at java.lang.Package.getPackageInfo(Package.java:350)
        at java.lang.Package.getDeclaredAnnotations(Package.java:375)
        at pack.Main.main(Main.java:26)

It seems that the problem is that the JDK 6 compiler target 1.5 adds "synthetic" and "abstract" attributes for the package-info classes that JDK 5 runtime doesn't understand.

Package-info, annotation type and Main class java source files are attached. As well as the output of the Jcoder tool for package-info classes compiled by different compilers.

Related information: 
       JVMS 3ed spec update: http://ccc.sfbay/6232928
       CRs: 6313196, 6232928

If this is a compiler bug, please reassign it to the java/compiler category.

Comments
EVALUATION This is an accomodation for a compiler bug. It is possible that there are people out there that are using an non-updated JDK6 which will generate code that JDK5 runtime won't recognize.
27-06-2007

WORK AROUND Compile with JDK 5
15-05-2007