Android: what happens if I add serialVersionUID to old serializable objects?

白昼怎懂夜的黑 提交于 2019-12-02 03:02:57
  1. If you give it the same value that is shown by running the serialver tool on the class as it is now, nothing happens.
  2. If you give it a different value, further deserializations of existing serial streams including that class will fail with an InvalidClassException.

It seems to me that the next time the app was updated by endusers it would try to deserialize data from disc

Correct.

find out that the serialVersionUID didn't match

Only if it really didn't match. If you follow the advice above, it will match.

overwrite the data with new data from the server/db/whatever

Incorrect. See above.

and after that you're fine.

No.

Am I correct in this assumption?

No.

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