aswathy
aswathy

Reputation: 831

How does receiver jvm that does deserialization, know which serialuuid has been used while serializing

How does receiver jvm that does deserialization using objectInputStream, know which serialuuid has been used while serializing using objectOutputStream. Given that sender and receiver are present in 2 different servers.

Upvotes: 0

Views: 39

Answers (1)

Thomas Kläger
Thomas Kläger

Reputation: 21435

Because when writing an object to an ObjectOutputStream the serialization logic not only writes the actual class name but also the serialVersionUid into the output stream.

Therefore the ObjectInputStream (on deserialization) can read the class name of the object to read and also the expected serialVersionUid of the class.

Upvotes: 1

Related Questions