Hi,
XStream 1.3.1 has no idea about a ConcurrentHashMap, therefore it will use a
SerializableConverter that is reflection based. However, the Java runtime
changed the implementation details for this type, therefore the XML marshalled
in Java 7 is incompatible when unmarshalled with Java 8. More changes might
have been made in newer Java versions.
XStream added support for the ConcurrentHashMap with XStream 1.4.3. Since this
version, the type is handled by the MapConverter, which does not depend on the
implementation details of the ConcurrentHashMap. However, it will not
unmarshal XML written by the SerializationConverter.
You realize, that we talk about stuff here, that changed a decade ago?
Derive an own converter from the MapConverter that handles the
ConcurrentHashMap. If the first child is not "unserializable-parents", just
call the super methods. If it is, you will need a compatibility mode in this
converter, that locates the elements of the map on its own and calls the
appropriate internal methods of the MapConverter.
BTW: Why do you try to use 1.4.8 and not 1.4.18?
Regards,
Jörg
Am Mittwoch, 10. November 2021, 02:50:23 CET schrieb Thirunavukkarasu
Dhanushkodi:
> Hi Team --
>
> We have serialized set of object along with concurrent hashmap in xstream
> 1.3.1 jar with java 7 version. however when we are upgrade the java 8 ,
> it's throwing an below error
>
> *Java 8 and xstream 1.3.1*
>
> com.thoughtworks.xstream.converters.reflection.ObjectAccessException: No
> such field java.util.concurrent.ConcurrentHashMap.segmentMask
> com.thoughtworks.xstream.converters.ConversionException: Could not call
> java.util.concurrent.ConcurrentHashMap.readObject() : No such field
> java.util.concurrent.ConcurrentHashMap.segmentMask
> ---- Debugging information ----
> message : Could not call
> java.util.concurrent.ConcurrentHashMap.readObject()
> cause-exception :
> com.thoughtworks.xstream.converters.reflection.ObjectAccessException
> cause-message : No such field
> java.util.concurrent.ConcurrentHashMap.segmentMask
> class : java.util.concurrent.ConcurrentHashMap
> required-type : java.util.concurrent.ConcurrentHashMap
> path :
> /java.util.concurrent.ConcurrentHashMap/java.util.concurrent.ConcurrentHashM
> ap/default/segmentMask line number : 5