This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 247464

Summary: Add hint: @XmlElement(required=false) is useless on primitives
Product: xml Reporter: hinnerdal <hinnerdal>
Component: JAXBAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.1   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description hinnerdal 2014-09-25 07:22:54 UTC
XmlElement annotation required=false is ignored if the field is a primitive


public int value;

this is exposed as
<xs:element name="value" type="xs:int"/>

Doing the same on Integer;

public Integer value;

<xs:element name="value" type="xs:int" minOccurs="0"/>

There should have been a warning, or hint to rewrite the int primitive to Integer in this case, because the annotation does not what the user may expect.

I have been bitten by this twice now, since I forgot this rule, and I needed to add some functionality in a webservice that should be backward compatible to existing clients, thus I need to add a field that is not required (minOccurs="0") and clients broke horribly when adding this as a primitive, and I thought the annotation would work.