Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333698 - JAXB: XmlList not being handled for array types when bootstrapping via TypeMappingInfo
Summary: JAXB: XmlList not being handled for array types when bootstrapping via TypeM...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: David McCann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-06 16:12 EST by David McCann CLA
Modified: 2022-06-09 10:04 EDT (History)
0 users

See Also:


Attachments
Proposed fix + supporting testcase (39.97 KB, patch)
2011-01-10 15:00 EST, David McCann CLA
no flags Details | Diff
Proposed fix + supporting test case (40.02 KB, patch)
2011-01-10 15:08 EST, David McCann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David McCann CLA 2011-01-06 16:12:11 EST
@XmlList on an array property is not being processed when bootstrapping via  TypeMappingInfo.  The following test case can be used to reproduce the issue:

-----
public class XmlListTest {
  @XmlList
  public static Float[] f = new Float[] { 3.14f };

  public static void main(String[] args) throws Exception {
    TypeMappingInfo ti = new TypeMappingInfo();
    ti.setXmlTagName(new QName("FooFloatListType"));
    ti.setType(Float[].class);
    ti.setElementScope(ElementScope.Global);

    JAXBContext ctx = JAXBContextFactory.createContext(
        new TypeMappingInfo[] { ti }, 
        new HashMap<Object, Object>(),
        Thread.currentThread().getContextClassLoader());

    JAXBElement<Float[]> elt = new JAXBElement<Float[]>(
        ti.getXmlTagName(), Float[].class, f);

    JAXBMarshaller jm = (JAXBMarshaller) ctx.createMarshaller();
    StreamResult result = new StreamResult(System.out);
    jm.marshal(elt, result, ti);
  }
}
-----

If @XmlList is handled properly we would expect:
    
  <FooFloatListType><item>3.14 3.25</item></FooFloatListType>

But instead get:
  
  <FooFloatListType><item>3.14</item><item>3.25</item></FooFloatListType>
Comment 1 David McCann CLA 2011-01-10 15:00:19 EST
Created attachment 186416 [details]
Proposed fix + supporting testcase
Comment 2 David McCann CLA 2011-01-10 15:08:17 EST
Created attachment 186418 [details]
Proposed fix + supporting test case
Comment 3 David McCann CLA 2011-01-10 16:01:47 EST
Reviewed by:  matt.macivor@oracle.com
Tests:  jaxb/typemappinginfo/arraywithannotations/ArrayWithAnnotationsTestCases;  all unit tests pass as expected
Revision: 8794
Comment 4 David McCann CLA 2011-01-10 16:01:55 EST
Fixed.
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:04:44 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink