Posts

Showing posts with the label how defualt serialVersionUID is calculated

serialVerionUID in Java Object Serialization

What is serialVersionUID? The purpose of the " serialVersionUID "  is to keep track of different versions of a class in order to perform valid deserialization of objects. This SUID should be unique to a certain version of a class, and should be changed when there are any details change to the class, such as a new field, which would affect the structure of the serialized object. The serialization process associates a serialVersionUID (default if not explicitly defined) with each serialized instance of a class. This serialVersionUID is validated at the time of deserialization from the loaded class serialVersionUID, and in case of a mismatch InvalidClassException is thrown. Default serialVersionUID If a serializable class does not define serialVersionUID explicitly  then the serialization process automatically calculates a default serialVersionUID (by invoking  computeDefaultSUID()  method of  java.io.ObjectStreamClass...