javaee / jaxb-v2

Other
210 stars 100 forks source link

Unable generate class with Underscore character #487

Open glassfishrobot opened 16 years ago

glassfishrobot commented 16 years ago

Please above URL for issue filed for Netbeans.

Tried below customizations.

Got java.lang.IllegalArgumentException: trying to create the same field twice: firstName

Got [ERROR] compiler was unable to honor this property customization. It is attached to a wrong place, or its inconsistent with other bindings.

Environment

Operating System: All Platform: All URL: http://www.netbeans.org/issues/show_bug.cgi?id=128566

Affected Versions

[2.1.4]

glassfishrobot commented 16 years ago

Reported by gmpatil

glassfishrobot commented 16 years ago

snajper said: Correcting priority/reassigning.

glassfishrobot commented 15 years ago

thebert said: I would like to add further information. This seems to be related.

Like the initiator of the issue, I am using a customization:

<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema">

</jaxb:bindings>

In the case where the schema has these two elements:

<xs:element name="emp_id_0415" type="xs:decimal" default="0" minOccurs="0" msdata:Ordinal="2" /> <xs:element name="_emp_id_0415" type="xs:string" default="" minOccurs="0" msdata:Ordinal="3" />

We receive an error when compiling the generated class.

java.lang.IllegalArgumentException: trying to create the same field twice: empId0415

I believe this error occurs because the customization logic is not implemented, or not being run, when creating class variables for holding the instance values. Looking at the generated class, I see:

@XmlElement(name = "emp_id_0415", defaultValue = "0") protected BigDecimal empId0415;

@XmlElement(name = "_emp_id_0415", defaultValue = "") protected String EmpId0415;

Note the duplicate values. public String get_Emp_Id_0415() { return EmpId0415;

As you can see, the underscores in _emp_id_0415 have been preserved in the method names but have been stripped when generating the internal String "EmpId0415".

I believe this to be a serious problem negating many of the positive effects of the customization.

glassfishrobot commented 16 years ago

Was assigned to snajper

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAXB-487