The serialVersionUID must remain the same or deserialization will fail. After that it should work; dropped fields will be ignored, and added fields will be set to defaults (null / 0 / '\0' / false).
My serialVersionUID is the same, but datatypes of some fields have changed.
Some new fields have also been added, but as yosay they should be handled.
Also, the toString() method has changed
Anrd
"One of the best things you could do is to simplify a larger application into a smaller one by reducing its process and complexity - Fowler"
The only problem there would be the changed data types. I don't think serialization can handle that, but you would have to try first to make sure. Maybe it will work if primitive types are widened, or if reference types are assignable, but I doubt it to be honest.
Rob Prime wrote:I wouldn't know right away how to solve this.
Do you think it is possible to solve this at all? If you change a String to an int in a class, you have to all intents and purposes created a different class. It is hardly going to serialise and deserialise at all.
Instead of Serializable, use Eternalizable. Then write and read a version number. In the readExternal() method, check the version number and then read only those fields that are applicable to that version. Note that the serialVersionUID needs to be hard coded so that changes in the class do not cause the UID value to change.