Details
-
Type: Bug
-
Status: Closed
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
I didn't find a way to enforce the check that object sent to XStream implements Serializable interface.
I know that sometimes its usefull to serialize non-serializable objects but in most situations, it's a programming mistake. Because I may send objects that by nature are not Serializable and the designer of the class intended to make them not serializable so, he/she didn't take care of what fields are transient or put a custom Serialization code.
For example, your library premits serializing objects of class java.io.FileDescriptor. Try to do that and see the results of serialization then you will know that enforcing the check that Any object is serializable is important at some cases.
I recommend you to have a flag passed in the constructor of XStream that when set, enforces any object to be serialized to implement java.io.Serializable interface.
Thanks for this nice library,
Hi Ali,
XStream is especially designed to convert objects, that do not implement Serializable. For XStream this is no requirement at all. You might enforce such a behaviour though by implementing a Converter, that just throws UnsupportedOperationException in marshal() and that matches any type. You must register this converter with a priority one above the ReflectionConverter, which is uses -20 (PRIORITY_VERY_LOW).