eclipse-ee4j / jaxb-ri

Jaxb RI
https://eclipse-ee4j.github.io/jaxb-ri/
BSD 3-Clause "New" or "Revised" License
204 stars 111 forks source link

From property usPrice xjc generates getUSPrice, but should be getUsPrice; the same for the setter. #1149

Open Tomas-Kraus opened 7 years ago

Tomas-Kraus commented 7 years ago

In the modify-marshal sample there is in the po.xsd:

<xsd:element name="USPrice" type="xsd:decimal"/>

xjc generates an property usPrice with getter and setter getUSPrice and setUSPrice.

But if you set @XmlAccessorType(XmlAccessType.PROPERTY)on class Item, and you put the @XmlElement(name = "USPrice", required = true) on the getter or setter of usPrice, then you will the that the getter and setter should be called getUsPrice and setUsPrice.

Tomas-Kraus commented 6 years ago
perceptron8 commented 1 year ago

I've encountered very similar problem today. Generated accessor names seem to be (sometimes!) incompatible with JavaBeans convention (as @ericjvandervelden demonstrated).

In my case, it breaks ability to obtain PropertyDescriptor from java.lang.reflect.Field's name (using java.beans.Introspector of course).

Here's xsd fragment:

<xs:element name="URI" type="xs:anyURI"/>

And here's fragment of generated code:

@XmlElement(name = "URI", required = true)
@XmlSchemaType(name = "anyURI")
protected String uri;

public String getURI() {
    return uri;
}

public void setURI(String value) {
    this.uri = value;
}

According to JavaBean convention, if I'm not wrong, it should be either uri + getUri + setUri or URI + getURI + setURI. As a workaround I use case-insensitive string comparison, but this is fragile and, hopefully, temporary solution.

Please let me know if I can help.