Assuming that I have got completely different classes with different class names. Should I use different serialVersionUID in the classes?
If so, why is it necessary?
How does the JRE the deserialization exactly?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
no you don’t need different SUID (all classes can use 1 for it)
when an object is serialized the class identifier (package.name.ClassName) and SUID are both part of the header to identify the class the object belongs to and to ensure that there is no incompatibility between the writing side and the reading side
but when you change a class structurally (add/remove a field) you should set a new SUID for that class (during debugging you can let the JVM create a new one at runtime based on the .class file)