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.
|Summary:||Add hint: @XmlElement(required=false) is useless on primitives|
|Component:||JAXB||Assignee:||Svata Dedic <sdedic>|
|Issue Type:||ENHANCEMENT||Exception Reporter:|
Description hinnerdal 2014-09-25 07:22:54 UTC
background: XmlElement annotation required=false is ignored if the field is a primitive Example; @XmlElement(required=false) public int value; this is exposed as <xs:element name="value" type="xs:int"/> Doing the same on Integer; @XmlElement(required=false) 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.