Reputation: 243
since the serialVersionUid is static static
that does mean it is not serializable. From what i understand when deserialization happens before the object is returned to the previous state it was in, the serialVersionUid is compared to the class one and if equal the process finishes successfully otherwise exception is thrown.
But how does that happen? How does serialization know which serialVersionUid to look for since it doesn't have it saved? Or is the serialversionuid is saved in some kind of header during the process of serialization and later is extracted from there?
Thanks for the help in advance!
Upvotes: 1
Views: 42
Reputation: 13933
serialVersionUID is a special (final) static variable and it is used by during serialization (unlike standard static fields which are not serialized).
Here is a good explanation: https://howtodoinjava.com/java/serialization/serialversionuid/
Upvotes: 1