Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8145039

JAXB marshaller fails with ClassCastException on classes generated by xjc

    Details

    • Subcomponent:
    • Resolved In Build:
      b112
    • Verification:
      Not verified

      Backports

        Description

        XJC generates incorrectly annotation @XmlSchemaType for types like:
            <!-- Simple type list -->
            <xsd:simpleType name="LongList">
                <xsd:list>
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:unsignedInt"/>
                    </xsd:simpleType>
                </xsd:list>
            </xsd:simpleType>
            <!--- Complex test type -->
            <xsd:element name="typesLongList">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="in" type="tns:LongList"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>

        Follow-up marshalling of incorrectly generated classes triggers ClassCastException at runtime:
        java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
                at com.sun.xml.internal.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.print(RuntimeBuiltinLeafInfoImpl.java:1034)
                at com.sun.xml.internal.bind.v2.runtime.reflect.ListTransducedAccessorImpl.print(ListTransducedAccessorImpl.java:103)
                at com.sun.xml.internal.bind.v2.runtime.reflect.DefaultTransducedAccessor.writeLeafElement(DefaultTransducedAccessor.java:54)
                at com.sun.xml.internal.bind.v2.runtime.property.ListElementProperty.serializeBody(ListElementProperty.java:107)
                at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:345)
                at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:578)
                at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:326)
                at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:479)
                at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:313)
                at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:241)
                at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95)

          Issue Links

            Activity

            Hide
            aefimov Aleksej Efimov added a comment - - edited
            This bug was fixed in JDK9 as part of sync process with standalone JAXWS project. See JDK-8150174 for details. Changes to CTypeRef class solves the reported issue:
            http://hg.openjdk.java.net/jdk9/jdk9/jaxws/rev/ebff1bd3627a#l34.1
            Show
            aefimov Aleksej Efimov added a comment - - edited This bug was fixed in JDK9 as part of sync process with standalone JAXWS project. See JDK-8150174 for details. Changes to CTypeRef class solves the reported issue: http://hg.openjdk.java.net/jdk9/jdk9/jaxws/rev/ebff1bd3627a#l34.1
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/de1f0e168eeb
            User: aefimov
            Date: 2016-03-21 19:00:32 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/de1f0e168eeb User: aefimov Date: 2016-03-21 19:00:32 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/de1f0e168eeb
            User: lana
            Date: 2016-03-30 18:38:15 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/de1f0e168eeb User: lana Date: 2016-03-30 18:38:15 +0000

              People

              • Assignee:
                aefimov Aleksej Efimov
                Reporter:
                shadowbug Shadow Bug
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: