Why isn't the serialVersionUID automatically generated?

后端 未结 3 1908
一个人的身影
一个人的身影 2020-12-16 02:12

Why isn\'t the serialVersionUID automatically generated? I was running into an issue on an application server where apparently an old class was being cached.

3条回答
  •  悲&欢浪女
    2020-12-16 03:00

    It is automatically generated, based on the structure of the class. If the structure changes, the id is regenerated (according to the serialization specification it is a hashof the class).

    So you'd better define an explicit serialVersionUID.

提交回复
热议问题