<?xml version="1.0" encoding="UTF-8"?>
<!--

DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.

The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License").  You
may not use this file except in compliance with the License.  You can
obtain a copy of the License at
http://glassfish.java.net/public/CDDL+GPL_1_1.html
or packager/legal/LICENSE.txt.  See the License for the specific
language governing permissions and limitations under the License.

When distributing the software, include this License Header Notice in each
file and include the License file at packager/legal/LICENSE.txt.

GPL Classpath Exception:
Oracle designates this particular file as subject to the "Classpath"
exception as provided by Oracle in the GPL Version 2 section of the License
file that accompanied this code.

Modifications:
If applicable, add the following below the License Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyright [year] [name of copyright owner]"

Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license."  If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above.  However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.

        -->
<!DOCTYPE book [
<!ENTITY % ents SYSTEM "docbook.ent">
%ents;
]>
<section version="5.0" xml:id="deployment-runtime-errors" xml:lang="en"
         xmlns="http://docbook.org/ns/docbook"
         xmlns:xlink="http://www.w3.org/1999/xlink"
         xmlns:ns5="http://www.w3.org/1999/xhtml"
         xmlns:ns3="http://www.w3.org/2000/svg"
         xmlns:ns="http://docbook.org/ns/docbook"
         xmlns:m="http://www.w3.org/1998/Math/MathML">
    <title>Runtime Errors</title>

    <section xml:id="Illegal_class_modifiers_for_package_info__0x1600">
        <title>Illegal class modifiers for package-info: 0x1600</title>

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

        <informalexample>
            <programlisting language=""><![CDATA[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)]]></programlisting>
        </informalexample>

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

        <para>Here is what's happening. Java5 added a new class file modifier
        attribute called <literal>ACC_SYNTHETIC</literal>, 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
        <filename>package-info.java</filename> is compiled into
        <filename>package-info.class</filename>, javac in Java5 apparently only put
        0x0600 (= <code>ACC_ABSTRACT|ACC_INTERFACE</code>.) Some time during
        Java6 development, someone filed <link
        xlink:href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6232928">a
        bug, saying it should also include <literal>ACC_SYNTHETIC</literal>
        bit</link>, since it was a synthesized class.</para>

        <para>Later <link
        xlink:href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6313196">it
        is discovered that the corresponding VM change needs to be made to
        allow this 0x1600 combination</link>, but apparently no one realized
        the real implication of this --- namely, 0x1600 will break all the
        past JVMs. Of course, this problem is <link
        xlink:href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6553734">eventually
        discovered</link>, but as of this writing there's still no fix for
        this.</para>

        <para>So as you see, this is why the only workaround is to use javac
        from Java5.</para>
    </section>
</section>
