jaxb-api
jaxb-api copied to clipboard
generateIsSetMethod generates dangerous boolean code
xjc generates code that does not properly autobox when 'generateIsSetMethod' is used. I reported this for integers as issue 667, but that could be worked around with an isSet method. However, booleans do not get an isSet method!
Generated code:
@XmlAttribute(name = "includeChildren") protected Boolean includeChildren;
With generateIsSetMethod: public boolean isIncludeChildren()
{ return includeChildren; }
Without: public Boolean isIncludeChildren() { return includeChildren; }
Environment
Operating System: All Platform: All
Affected Versions
[2.1.12]
- Issue Imported From: https://github.com/javaee/jaxb-v2/issues/679
- Original Issue Raised By:@glassfishrobot
- Original Issue Assigned To: @glassfishrobot
@glassfishrobot Commented Reported by lucasmo
@glassfishrobot Commented snajper said: Please see 131. We cannot fix this as we have to maintain backward compatibility.
-
-
- This issue has been marked as a duplicate of 131 ***
-
@glassfishrobot Commented lucasmo said: I do not believe this is a duplicate of issue 131. Issue 131 reports as a bug that isIncludeChildren returs a Boolean. I am reporting the opposite: that it's a bug for it to return boolean. This Boolean return is the default behavior, which should be used.
The bug here is when the extension 'generateIsSetMethod' is used, it turns on some rather undocumented side effects; for instance, the signature turns to boolean, not Boolean. If this was a resolution for 131, it was undocumented.
The problem with this is - when generateIsSetMethod is used - is that there is NO POSSIBLE WAY to look at your xml boolean values without using introspection. Calling object.isIncludeChildren() should not throw a NPE under any circumstances.
@glassfishrobot Commented snajper said: Ah, I see what you mean. The trouble is the spec specifies the method signature to be specifically "boolean", and we can't change the signature because there might be code out there which relies on it.
Fixing this requires update to the spec itself. I'll mark 667 as a duplicate of this one, as both should be fixed at once.
@glassfishrobot Commented snajper said:
-
-
- Issue 667 has been marked as a duplicate of this issue. ***
-
@glassfishrobot Commented Was assigned to snajper
@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-679
@lukasj I don't see any references about 'generateIsSetMethod' in the API, only in spec documentation. Is it correct to maintain this issue here instead of eclipse-ee4j/jaxb-ri?
Regards, Antonio.