XStream - 在向界面添加函数后使用以前的序列化对象?
我使用 XStream 序列化实现接口的对象“A”:
interface MyInterface {
String functionA();
}
MyInterface a = new MyInterface() {...}
现在接口发生了变化,并且我添加了另一个功能:
interface MyInterface {
String functionA();
String functionB();
}
尝试反序列化它现在失败(列出的例外),因为接口发生了变化 - 但我可以让它以某种方式工作吗?
这是例外:
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)
我查看了 XStream FAQ ,但没有任何改变功能。有什么想法吗?
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 exception), 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来更像是匿名类存在问题,而不是 XStream 或序列化机制本身。这些是真实的签名吗?您是否尝试过更改命名类(非匿名类)的签名?
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)?