users@jaxb.java.net

Re: JAXB instantiates extra HashSet layer

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 11 Jul 2006 12:08:24 -0700

Dmitri Colebatch wrote:
> Hi Thang,
>
> I should have replied to this earlier but have been behind on my inbox.
>
> When unmarshalling collections JAXB uses XmlJavaTypeAdapter to adapt
> each item in the set (as opposed to the collection itself).
>
> So, without going into it to much, what I think is happening in your
> case is that JAXB is getting the result of your SetAdapter and
> sticking in a HashSet (as you've noticed).

This analysis is correct.

There has been a confusion among us, inside the spec, and in the code as
to how adapters can and should work. One area where things often break
is this "adapting collection" area.

There has been several bugs filed around this. We need to fix those. In
the meantime, consider a verbose but more predictable workaround like [1].


[1]
https://jaxb.dev.java.net/guide/XML_layout_and_in_memory_data_layout.html#Pair_property
-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com