7.5. Runtime Errors

7.5.1. Illegal class modifiers for package-info: 0x1600

When you compile your sources files with JDK from Java6 and try to run it on Java5 JVMs, you may see a ClassFormatError at runtime like this:

main" java.lang.ClassFormatError: Illegal class modifiers in class com/alu/parentalcontrol/jaxb/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.getAnnotation(Package.java:361)
at com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getPackageAnnotation(RuntimeInlineAnnotationReader.java:125)
at com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getPackageAnnotation(RuntimeInlineAnnotationReader.java:53)
at com.sun.xml.bind.v2.model.impl.TypeInfoImpl.parseElementName(TypeInfoImpl.java:122)
at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.<init>(ClassInfoImpl.java:166)

This is due to a bug, and so far the only way to fix this is to compile your project with JavaSE 5.

Here is what's happening. Java5 added a new class file modifier attribute called ACC_SYNTHETIC, whose bit value is 0x1000. This attribute marks types and methods that are not present in the source file but generated by the compiler. When package-info.java is compiled into package-info.class, javac in Java5 apparently only put 0x0600 (=ACC_ABSTRACT|ACC_INTERFACE.) Some time during Java6 development, someone filed a bug, saying it should also include ACC_SYNTHETIC bit, since it was a synthesized class.

Later it is discovered that the corresponding VM change needs to be made to allow this 0x1600 combination, but apparently no one realized the real implication of this --- namely, 0x1600 will break all the past JVMs. Of course, this problem is eventually discovered, but as of this writing there's still no fix for this.

So as you see, this is why the only workaround is to use javac from Java5.

Terms of Use; Privacy Policy; Copyright ©2013-2017 (revision 20160708.bf2ac18)
Please Confirm