jaxb-ri icon indicating copy to clipboard operation
jaxb-ri copied to clipboard

Illegal class inheritance loop. Outer class NestedBinaryData may not subclass from inner class: NestedBinaryData -> [Help 1]

Open Tomas-Kraus opened this issue 11 years ago • 6 comments

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

Tomas-Kraus avatar Mar 26 '13 13:03 Tomas-Kraus

  • Issue Imported From: https://github.com/javaee/jaxb-v2/issues/953
  • Original Issue Raised By:@glassfishrobot
  • Original Issue Assigned To: @glassfishrobot

Tomas-Kraus avatar Sep 21 '18 16:09 Tomas-Kraus

@glassfishrobot Commented Reported by francisandre

Tomas-Kraus avatar Mar 26 '13 13:03 Tomas-Kraus

@glassfishrobot Commented yaroska said: Thank you for the submission. I'll look at it.

Tomas-Kraus avatar Mar 26 '13 13:03 Tomas-Kraus

@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>

Tomas-Kraus avatar Apr 05 '13 07:04 Tomas-Kraus

@glassfishrobot Commented Was assigned to yaroska

Tomas-Kraus avatar Mar 26 '13 13:03 Tomas-Kraus

@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-953

Tomas-Kraus avatar Apr 24 '17 12:04 Tomas-Kraus