scala类序列化,无法修复SerialVersionUID
我目前正在测试远程参与者在 Android 和 Windows 之间进行通信。参与者远程发送不同的类,我在其中设置了serialVersionUID。
这是我的序列化类的代码:
@SerialVersionUID(13.asInstanceOf[Long]) case class IdentifyMessage(userName : String, user : User, code : Int)
问题是远程参与者调试说存在不兼容类的问题:
caught java.io.InvalidClassException: scala.actors.remote.Node; local class incompatible:
stream classdesc serialVersionUID = -6610463074147725500, local class serialVersionUID = -7525549079045563153
为什么我的 SerialVersionUID 对于编译器来说不重要?
如何修复serialVersionUID?或者也许还有另一个问题?
谢谢
I'm currently testing remote actors to communicate between Android and Windows. Actors remote sends differents classes where I set the serialVersionUID.
This is the code of my serialized class:
@SerialVersionUID(13.asInstanceOf[Long]) case class IdentifyMessage(userName : String, user : User, code : Int)
the problem is that the remote actors debug says there is a problem with incompatible class:
caught java.io.InvalidClassException: scala.actors.remote.Node; local class incompatible:
stream classdesc serialVersionUID = -6610463074147725500, local class serialVersionUID = -7525549079045563153
Why my SerialVersionUID doesn't matter for compiler?
How do I do to fix serialVersionUID? or maybe there is an another problem?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于某种原因,使用长版本的 13、13l 效果更好:
在 REPL 中测试:
更新
我还尝试将其作为程序运行;像这样:
...并得到:
For some reason using the long version of 13, 13l, works better:
Tested in REPL with:
Update
I also tried to run it as a program; like this:
... and got: