Issue Details (XML | Word | Printable)

Key: JAXB-510
Type: Bug Bug
Status: Resolved Resolved
Resolution: Cannot Reproduce
Priority: Major Major
Assignee: jaxb-issues
Reporter: jasonzhang2002gmailcom
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
jaxb

optionalProperty="primitive" does not work

Created: 05/Jun/08 05:18 AM   Updated: 24/Oct/12 08:22 AM   Resolved: 28/Jul/08 05:43 AM
Component/s: xjc
Affects Version/s: 2.1.7
Fix Version/s: 2.1.8

Time Tracking:
Not Specified

Environment:

Operating System: All
Platform: All


Issuezilla Id: 510
Tags:
Participants: jasonzhang2002gmailcom, jaxb-issues, Martin Grebac, mdarwin and smbdy


 Description  « Hide

My Xml file is like this

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://net.sf.webcommand/cmdmeta"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://net.sf.webcommand/cmdmeta"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0">
<annotation>
<appinfo>
<jxb:globalBindings optionalProperty="primitive">
<jxb:serializable uid="1" />
</jxb:globalBindings>
</appinfo>
</annotation>

<complexType name="foo">
<sequence>
<element name="display" type="boolean" minOccurs="0">

</element>
</sequence>
</complexType>

</schema>

when I run the command, /xjc.sh -d src meta.xsd, the method signature for
display is always Boolean instead of primitive boolean type.

I tried JAXB-2.1.7, JAXB-2.0.5 and JAXB from java 6.
All of them gave me reference Boolean type instead of primitive boolean type.

thanks

-jason



Martin Grebac added a comment - 28/Jul/08 05:43 AM

The problem is in minOccurs. If you specify minOccurs=1, then you get boolean
correctly, because there's no need to represent null value.


smbdy added a comment - 27/May/11 03:59 AM

From the spec "If the attribute’s value is "primitive", it binds as it did in JAXB 1.0."

I'm getting primitive type boolean using JAXB 1.0 in this case, so I consider this is a bug. Is there any way to force JAXB 2 generate primitives when minOccurs=0 like JAXB 1 does ?


mdarwin added a comment - 24/Oct/12 08:22 AM