I have a question about serializing and deserializing objects when changing a class field.
If an object of type MyClass
MyClass {
String str1;
LinkedList mylist = new LinkedList();
String str2;
}
was serialized to a file.
Then I changed the code that changed the definition of MyClass to
MyClass {
String str1;
LinkedList mylist = new LinkedList();
Map myMap = new HashMap();
}
After that, I will deserialize the object from the file to the MyClass object using the modified code. This is normal? Will any exceptions be thrown during deserialization? I want to reuse an old object. That is, I want de-serialization to be possible. Therefore, I hope that there will be no exceptions.
Thank.
source
share