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

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

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


Operating System: All
Platform: All

Issuezilla Id: 510
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:jxb="" jxb:version="2.0">
<jxb:globalBindings optionalProperty="primitive">
<jxb:serializable uid="1" />

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



when I run the command, / -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.



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