cannot deserialize com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl any more

75 views
Skip to first unread message

Andreas Kosmala

unread,
Oct 13, 2022, 11:34:31 AM10/13/22
to XStream User
Hello Jörg,
(first thanks for maintaining this helpful project!)
Very surprising problem: deserialization of XMLGregorianCalendarImpl works with (corretto) jdk 1.8.0_322, but does NOT WORK with jdk 1.8.0_342!
Why? Because in 1.8.0_342 XMLGregorianCalendarImpl contains method readObject(ObjectInputStream) which makes SerializableConverter.canConvert() return true.
But  readObject(ObjectInputStream) is private! So some steps later deserialization leads to "com.thoughtworks.xstream.converters.ConversionException: Cannot deserialize object with new readObject()/writeObject() methods"
When I make SerializableConverter.canConvert() return false (via debugger expression evaluation - old trick ;-)) the (lower prioritized) RefectionConverter is used instead of SerializableConverter (as is the case in jdk 1.8.0_322) and everything works like a charm :-)
Could you add a check in SerializableConverter.canConvert() whether read/writeObject methods are not only existent but also accessible? That should solve the problem.
Thanks in advance and kind Regards
Andreas

Andreas Kosmala

unread,
Oct 14, 2022, 10:53:22 AM10/14/22
to XStream User
Problem was different that I thought first: if fact  XMLGregorianCalendarImpl has changed in 1.8.0_342. Therefor it is serialized differently than it was before. 
So old Strings serialized with versions <342 cannot be deserialized with 342 any more. Strings serialized with 342 can be deserialized successfully.
This change was unexpected to me, but xstream works fine.

Jörg Schaible

unread,
Nov 17, 2022, 5:47:23 PM11/17/22
to xstrea...@googlegroups.com
Hi Andreas,

you might write an own converter for XMLGregorianCalendar that writed the date
as single value in ISO 8601 format. Then you're independent of such internal
changes.

Regards,
Jörg
Reply all
Reply to author
Forward
0 new messages