How can I find out the serialVersionUID of a serialized Java object?

前端 未结 3 1408
春和景丽
春和景丽 2021-02-13 16:28

I have several serializable classes that were compiled without specifying a serialVersionUID. I now need to add some data members to these classes but wish to preserve some alre

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-13 17:01

    If you haven't modified the code yet you could probably run the serialver tool (part of the JDK) and see what it generates. I believe that will get you what the calculated seriVersionUID is.

    Here is a brief article on serialver.

提交回复
热议问题