jaxb-ri
jaxb-ri copied to clipboard
Illegal class inheritance loop. Outer class NestedBinaryData may not subclass from inner class: NestedBinaryData -> [Help 1]
Hi
The following xsd snippet contains a legal element "BinaryData" embedded twice with the same name as: <xs:complexType name="DeviceInstance_t"> xs:sequence <xs:element name="BinaryData" minOccurs="0"> xs:complexType xs:sequence <xs:element name="BinaryData" maxOccurs="unbounded"> xs:complexType xs:sequence <xs:element name="Data" type="xs:base64Binary" minOccurs="0"/> </xs:sequence> <xs:attribute name="Id" type="xs:string" use="optional"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType>
As xjc generates an embedded Java class BinaryData inside a embedded Java class BinaryData, the java compiler complains that the class DeviceInstanceT.BinaryData.BinaryData cannot shadow teh class DeviceInstanceT.BinaryData. Right;
So in order to avoid this name clash, I am using jaxb binding to change the name of the most inner java class as NestedBinaryData with the following binding
<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" schemaLocation = "knx_project.xsd" node="/xs:schema"> <jxb:bindings node="//xs:complexType[@name='DeviceInstance_t']"> <jxb:bindings node="./xs:sequence"> <jxb:bindings node="./xs:element[@name='BinaryData']"> <jxb:bindings node=".//xs:element[@name='BinaryData']"> <jxb:class name='NestedBinaryData'/> </jxb:bindings> </jxb:bindings> </jxb:bindings> </jxb:bindings> </jxb:bindings>
But xjc complains that: (xjc) on project KNXNetIPServer: Illegal class inheritance loop. Outer class NestedBinaryData may not subclass from inner class: NestedBinaryData -> [Help 1]
In my opinion, this error is invalid because the jxb:class renaming should apply only to the inner most BinaryData element, not the intermediate one.
Rgds
Environment
WXP SP3, Sun JDK 1.6.0_35
- Issue Imported From: https://github.com/javaee/jaxb-v2/issues/953
- Original Issue Raised By:@glassfishrobot
- Original Issue Assigned To: @glassfishrobot
@glassfishrobot Commented Reported by francisandre
@glassfishrobot Commented yaroska said: Thank you for the submission. I'll look at it.
@glassfishrobot Commented francisandre said: Hi
I am stuck with the same issue on a different schema snippet. Could you have a look?
Description Resource Path Location Type Illegal class inheritance loop. Outer class JaXBParameterTypes may not subclass from inner class: JaXBParameterTypes (org.codehaus.mojo:jaxb2-maven-plugin:1.5:xjc:xjc:generate-sources) pom.xml /KNXNetIP line 23 Maven Build Problem
<jxb:bindings node="//xs:element[@name='ParameterTypes']"> <jxb:class name='JaXBParameterTypes' implClass='knxnetip.xml.bindings.ParameterTypes'> </jxb:class> </jxb:bindings>
<xs:element name="ParameterTypes" minOccurs="0"> xs:complexType xs:sequence <xs:element name="ParameterType" type="knx:ParameterType_t" maxOccurs="unbounded"> xs:annotation xs:documentationregistration-relevant set</xs:documentation> </xs:annotation> </xs:element> </xs:sequence> </xs:complexType> </xs:element>
@glassfishrobot Commented Was assigned to yaroska
@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-953