14 - Java Serialization Versioning - Theory

@Rishi Srivastava -------------------------------------------------------------------------------- Chapter 04 - Serialization versioning -------------------------------------------------------------------------------- Suppose we have a class, and we have serialized its object to a file on the disk, and due to some new requirements, we added/removed one field from our class. Or just added a new utility method to it. Now, if we try to deserialize the already serialized object, we will get InvalidClassException. When we serialize a class, each class has a unique identification number associated with it. Its also called stream unique identifiers, more commonly known as serial versionUIDs. If we do not specify this number by declaring a static final long field named serialVersionUID, the system automatically generates it at runtime by applying a cryptographic hash function (SHA-1) to the structure of the class. This value is affected by the names of the class, the interfac
Back to Top