Attribute with default generates different types for get and set methods · Issue #825 · javaee/jaxb-v2 (original) (raw)

This is a duplicate of bug 511 which is closed, but I believe should be reopened.

For example the following XSD attribute declaration:

<xs:attribute name="integer-with-default" type="xs:int" default="131"/>

Will generate the following getter/setter methods:

public int getIntegerWithDefault() { ...
public void setIntegerWithDefault(Integer value) { ...

Attached is a testcase that utilizes Apache Commons BeanUtils to show that PropertyUtils does not find getter and setter methods in certain cases, regardless of whether the -enableIntrospection argument is passed to XJC.

The test produces the following output:

[java] Get error: Property 'boolean' has no getter method in class 'class normal.Document'
[java] Set error: Property 'booleanWithDefault' has no setter method in class 'class normal.Document'
[java] Set error: Property 'integerWithDefault' has no setter method in class 'class normal.Document'
[java] Get error: Property 'boolean' has no getter method in class 'class normal.Document'
[java] Expected false, got true
[java] Expected 2, got 131
[java] Set error: Property 'booleanWithDefault' has no setter method in class 'class switched.Document'
[java] Set error: Property 'integerWithDefault' has no setter method in class 'class switched.Document'
[java] Expected false, got true
[java] Expected 2, got 131

Affected Versions

[2.2.3u1]