Details
-
Type: Bug
-
Status: Closed
-
Priority: Minor
-
Resolution: Won't Fix
-
Affects Version/s: 0.1
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
When inheriting from ArrayList or LinkedList the serialized xml will not contain any new members of the object.
Example test case :
public class XStreamTest extends TestCase
{
public void testInheritance()
}
class LinkedListChild extends ArrayList
{
private int id = 2;
public int getId()
{ return id; }public void setId(int id)
{ this.id = id; }}
I would suggest using composition instead of inheritence and then XStream would work just dandy.
If you must use your extended List you might need to use the alias mechanism. You can either set the implementation to use when the List (or LinkedList) interface is encountered i.e.
xstream.alias( "list", List.class, MyExtendedList.class );
or you can just alias the specific element your MyExtendedList.class refers to i.e.
xstream.alias( "weirdo-list", MyExtendedList.class )
Joe will correct me if I'm wrong but I suggest composition anyway.