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 ...

Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.