Hiho Jörg,
The problem appears to be that xstream is (in contrast to the default
serialization?) automatically trying to serialize parent classes as
well... Even if they aren't serializable (I know that part is not a bug,
but a feature ;))
Can I turn that off somehow? This is what breaks my xstream, because
there are some objects referenced there that cannot be serialized using
a standard ObjectOutputStream. And they shouldn't be in the xml in the
first place, because they are (although not marked) transient. I really
don't want to have to recheck my entire hierarchy for that.
Or should I really implement a serialization method for the parent?
Parent data is stored during serialization, but I just moved that to the
child classes (parent is abstract and most data in it not serialized
anyway)...
Looking forward to hearing from you,
Robert.
Am 12.03.2014 15:19, schrieb Jörg Schaible:
Hi Robert,
Robert Feustel wrote:
Hello there,
I'm trying to serialize a complex object that I wrote
a custom serializer (write/readObject() method) for. Now, when I try
running this through xstream it appears that this custom serializer is
completely ignored... It's a hierarchical dataset containing multiple
instances (in depth as well as width) of custom objects with custom
serialization methods...
Is there a way to tell xstream to only use
the serialization that java uses... The one I specified?
XStream respects those serializers by default (*), why do you think
otherwise? Marshal such an object to XML and back again and ensure either
with the debugger or System.println() calls that your methods have been
called.
*) Without XStream annotations or further configuration, just by:
==================== %< ====================
XStream xstream = new XStream();
String xml = xstream.toXML(yourObject);
YourType yourObjectAgain = (YourType)xstream.fromXML(xml);
==================== %< ====================
However, you might have influenced this depending on your XStream setup.
Cheers,
Jörg
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email