Java - Modifying serialVersionUID of binary serialized object

前端 未结 4 781
感情败类
感情败类 2021-01-07 08:37

A few months back I serialized a java.io.Serializable object into a file. Now I need to read the contents, but since then the serialVersionUID has changed, and now I\'m get

4条回答
  •  醉话见心
    2021-01-07 08:43

    As a hack, you can generate the serialVer your jvm is probably using using the serialver tool:

    serialver -classpath whatever com.foo.bar.MyClass

    If you then manually set the serialVerUID in your class it ought to match and you ought to be able to load, assuming you haven't changed the class in such a way as to invalidate.

提交回复
热议问题