Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Thanks,

Raj

like image 980
Raj Avatar asked Oct 30 '22 03:10

Raj


1 Answers

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.

like image 153
Elliott Frisch Avatar answered Nov 10 '22 21:11

Elliott Frisch