Dealing with Multiple Versions
One of the more frustrating aspects of serialization is in the area of versioning. If you serialize a class, change it, and then try to deserialize the old data into an object with the new class definition, the deserialization will fail. Although there might be many cases in which you want it to fail, there's a pretty good chance that you really wanted to read the old data, ignoring any fields that aren't there, and using default initialization values for the fields that are there.
When the serialization libraries write out a serialized object, they first compute a serialization version number called the serial version UID. The version number is a hash value computed from the various methods and member variables ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access