Friday, 8 April 2016

Why it is recommended for all serializable classes to declare serialVersionUID explicitly ?


Recommendation : All Serializable classes should explicitly declare serialVersionUID values

Reason : Default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and so it can lead to InvalidClassExceptions during deserialization. 

Conclusion : To guarantee a consistent serialVersionUID value across different java compiler implementations, a Serializable class must declare an explicit serialVersionUID value.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.