Raj Raj - 9 months ago 71
Java Question

Will different java versions create different serialVersionUID?

I have updated my java version from 1.6 to 1.8. When I try to deploy my project in weblogic (12c), I am getting below error.

java.io.InvalidClassException: org.springframework.beans.PropertyAccessException; local class incompatible: stream classdesc serialVersionUID = -5171479712008793097, local class serialVersionUID = 736080306599024264

Do I need to re generate serialVersionUID , which created using java version 1.6 ?

Please help




Yes, the compiler version matters. The Serializable Javadoc says (in part)

If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification. However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization.