Which class types can be serialized by XStream?
In contrast to the JDK XStream is not tied to a marker interface to serialize a class. XStream ships with some specialized converters, but will use reflection by default for “unknown” classes to examine, read and write the class’ data. Therefore XStream can handle quite any class, especially the ones referred as POJO (Plain Old Java Object). However, some types of classes exist with typical characteristics, that cannot be handled – at least not out of the box: • Objects that are based on threads or thread local data: Thread, Timer, ThreadLocal and so on. These classes keep different data for different threads and there’s no possibility to recreate a thread in a generic way nor recreating thread specific data. There might be special use cases, but this will always involve a custom converter where threads can be recreated in a specific way tied to that use case. • Class types that are based on generated classes. Such types have often names that are unique to the current process and will