我有以下XML:
<Person>
<siblings>
<siblings>
<Sibling>
<forename>Bob</forename>
...
</Sibling>
</sibings>
</siblings>
</Person>
我正在尝试解析Java对象:
public class Person() {
private Siblings siblings;
}
public class Siblings() {
private MyList<Sibling> siblings;
}
public class Sibling() {
private String forename;
}
Siblings
类使用java.util.List
的实现:
public class MyList<E> extends AbstractList<E>
implements List<E>, RandomAccess, Cloneable, java.io.Serializable {
// code
}
在转换过程中,我收到以下错误:
Exception in thread "main" com.thoughtworks.xstream.converters.ConversionException: Cannot deserialize object with new readObject()/writeObject() methods
---- Debugging information ----
message : Cannot deserialize object with new readObject()/writeObject() methods
class : utils.xtreamtest.MyList
required-type : utils.xtreamtest.MyList
converter-type : com.thoughtworks.xstream.converters.reflection.SerializableConverter
path : /Person/siblings/siblings
line number : 3
class[1] : utils.xtreamtest.Siblings
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2] : utils.xtreamtest.Person
version : 1.4.9
-------------------------------
我猜这是因为xstream不知道MyList
类是什么?我是否会使用别名来执行此操作,如果是这样,那么siblings
有两个级别。我将无法编辑源代码来添加注释。