users@jaxb.java.net

Re: JAXB instantiates extra HashSet layer

From: Kirill Grouchnikov <kirillcool_at_yahoo.com>
Date: Fri, 30 Jun 2006 11:57:41 -0700 (PDT)

You always have setAccessible on anything in the reflection. Under standard security manager, you can change any private member.

Kirill

"Thang X. Le" <tle_at_neptium.com> wrote: Hi Ed,
 
 
 Originally I did use a HashSet, and I found that POType.items
 is a HashSet containing HashSet. I thought maybe there
 is some cloning, so I changed the type to CopyOnWriteArraySet.
 Now nowhere in my code do I instantiate a HashSet, and yet
 POType items is a HashSet of CopyOnWriteArraySet. So
 I'm sure this HashSet is a product of JAXB.
 
 
 Logically, I'd assume JAXB performs the binding to an Items,
 uses the adapter to convert it to a Set, and then calls
 POType.setItems, to assign that Set to POType.items. But
 the call was never made, and yet POType.items, despite
 being a private field, is still instantiated (with a HashSet).
 JAXB-wise, why is it like that? And JVM/JLS-wise, how can
 that be possible?
 
 
 Thang Le
 
 
 On 30 Jun 2006 at 14:17, Ed Mooney wrote:
 
 
> Hi Thang,
>
> I'm wrong. Of course
>
> new java.util.concurrent.CopyOnWriteArraySet<Items.Item>()
>
> instantiates CopyOnWriteArraySet.
>
> Now, I'm baffled. Will poke around some more.
>
> Regards,
> --
> Ed Mooney |Sun Microsystems, Inc.|Time flies like
> Java Web Services |UBUR02-201 |an arrow, but
> Ed.Mooney_at_Sun.COM |1 Network Drive |fruit flies like
> 781-442-0459 |Burlington, MA 01803 |a banana. Groucho
>
> Ed Mooney wrote:
> > Hi Thang,
> >
> > I'm sure this is Java behavior not specific to JAXB, but I couldn't a
> > reference. Since Set is an interface, I'm speculating that HashSet is
> > the default implementation returned when you do something like
> >
> > Set<Items.Item> s = new
> > java.util.concurrent.CopyOnWriteArraySet<Items.Item>()
> >
> > I think the answer should be here[1], but I couldn't find it right away.
> >
> > Regards,
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
 
 
 
 

                 
---------------------------------
Do you Yahoo!?
 Next-gen email? Have it all with the all-new Yahoo! Mail Beta.