users@jaxb.java.net

Default marshalling of JRE classes

From: Herve Bitteur <Herve.Bitteur_at_Sun.COM>
Date: Wed, 25 Oct 2006 14:35:07 +0200

Hello,

I made a few attempts to test default marshalling of java.awt.Point and
java.awt.Dimension.
They both lead to stack overflow, because of infinite recursion.
My understanding is that this is due to the default XmlAccessType being
PUBLIC_MEMBER. So every public getter/setter pair and every public field
gets serialized.

For class Point, we have fields x & y, plus getter/setter pair
getLocation/setLocation. The getLocation allocates a new Point, whose
getLocation allocates a new Point, etc...
For class Dimension, we have fields width & height, plus getter/setter
pair getSize/setSize. The getSize method allocates a new Dimension, etc...

For example, marshalling a Dimension gives the following XML endless stream:

    <dimension>
        <width>4</width>
        <height>35</height>
        <size>
            <width>4</width>
            <height>35</height>
            <size>
                <width>4</width>
                <height>35</height>
etc...

Ma question: Is there a way to specify a different policy, for example
FIELD by default? Or just for the current application (if this makes
sense, I'm not sure)

Bye
/Hervé
-- 
<http://www.sun.com> 	*Hervé Bitteur*
Software Program Manager
*Sun Microsystems, Inc.*
13, Avenue Morane Saulnier
78142 Vélizy Cedex FRANCE
Phone +33 1 34 03 01 12
Mobile +33 6 86 49 04 14
Fax     +33 1 34 03 07 56
Email   herve.bitteur_at_sun.com
Skype hbitteur <skype:hbitteur?call>