I'm working with JAXB's xjc tool to generate Java classes from an AUTOSAR XSD file and encountered an IllegalArgumentException indicating an illegal class inheritance loop. Here's the error message I received:
Exception in thread "main" java.lang.IllegalArgumentException: Illegal class inheritance loop. Outer class TargetIPduRefElement may not subclass from inner class: TargetIPduRefElement
at [email protected]/com.sun.codemodel.JDefinedClass._extends(JDefinedClass.java:247)
at [email protected]/com.sun.tools.xjc.generator.bean.ImplStructureStrategy$1._extends(ImplStructureStrategy.java:96)
at [email protected]/com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:187)
at [email protected]/com.sun.tools.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:141)
at [email protected]/com.sun.tools.xjc.model.Model.generateCode(Model.java:259)
at [email protected]/com.sun.tools.xjc.Driver.run(Driver.java:365)
at [email protected]/com.sun.tools.xjc.Driver.run(Driver.java:198)
at [email protected]/com.sun.tools.xjc.Driver._main(Driver.java:117)
at [email protected]/com.sun.tools.xjc.Driver$1.run(Driver.java:76)
Has anyone encountered a similar issue and found a way to resolve it? I'd appreciate any insights or suggestions on how to debug this problem.
In order to make xjc compile your XSD (from your link), I had to add the following binding file
This will resolve the problem encounter without any binding file :
typesafeEnumMaxMembers="1024"will solve the enum not being generated (adjust according max members)BGCOLORattributeTARGETIPDUREFandCOMPUSCALESIf not using jaxb3/4 (jakarta-based), you can change the header of the file to make it compatible to jaxb2 with the following