开发者

XStream - use previous serialized object after adding a function to the interface?

I use XStream to serialize an object "A" implementing an interface :

interface MyInterface { 
       String functionA();
}

MyInterface a = new MyInterface() {...}

Now the interface changed , and I added another function:

interface MyInterface {
       String functionA();
       String functionB();
}

Trying to deserialize it now fails (with the listed exce开发者_StackOverflow中文版ption), because the interface changed - But can I make it work somehow?

This is the exception:

com.thoughtworks.xstream.mapper.CannotResolveClassException: com.cf.TestSaveSerialization$1 : com.cf.TestSaveSerialization$1
    at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:68)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38)
    at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:71)

I've looked at the XStream FAQ , but there's nothing about changing functions. Any idea?


It sounds more like there's an issue with the anonymous class, rather than XStream or the serialization mechanism itself. Are these the actual signatures? Have you tried altering the signature of a named class (a non-anonymous class)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜