Array classes with serialVersionUID?

那年仲夏 提交于 2019-12-08 20:04:24
Paul Wagland

I think that the answer to your question is to read up on serialVersionUID. In particular, you often want to specify this on your classes to be able to deal with the fact that classes change over time.

The comment that you are referring to is saying that you cannot set a serialVersionUID on arrays. If this was true, and the serialVersionUID always needed to match, then your array would have serious issues, and would be very fragile with respect to serialization. To counter this, the language designers decided that array (de)serialization would ignore the serialVersionUID, thus side-stepping the problem that it cannot be defined.

I haven't figured why I would need to do his.

You don't. You can't. There is no syntax for defining array classes, let alone their serialVersionUID members.

That's also why checking it would be completely pointless. There is nothing about the class that could possibly change.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!