castor-data-binding / castor

http://castor-data-binding.github.io/castor/
35 stars 29 forks source link

Generated classes invoke undefined constructor Object(String) #80

Open mvglasow opened 4 years ago

mvglasow commented 4 years ago

After generating a set of Java classes from an XSD with Castor, I see some (not all) of them cause a compiler error for invoking a non-existent constructor

java.lang.Object(String)

The XSD was downloaded from https://datex2.eu/schema/2/2_0/DATEXIISchema_2_2_3.xsd and then converted with the command line

java -cp "*" org.exolab.castor.builder.SourceGeneratorMain -i DATEXIISchema_2_2_3.xsd -types j2

Content of castorbuilder.properties:

org.exolab.castor.builder.javaclassmapping=type
org.exolab.castor.builder.javaVersion=5.0
org.exolab.castor.builder.nspackages=\
   http://example.com/schema/foo=com.example.schema.foo
org.exolab.castor.builder.primitivetowrapper=true

This affects almost exclusively classes whose name begins with an underscore, where the offending code looks like this:

/**
 * Field targetClass.
 */
private java.lang.Object targetClass = new java.lang.Object("ContactDetails");

public _ContactDetailsVersionedReference() {
    super();
    setTargetClass(new java.lang.Object("ContactDetails"));
}

The root element, D2LogicalModelfor the XSD mentioned, is also affected, though here it is the modelBaseVersion property.

Tested on 1.4.1 as downloaded from Maven Central.