This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Originally posted by James Clarke: I was generating serialVersionUID for some of my classes(using serialver), which even though are not implementing Serializable are extending other classes which are Serializable.
as far as I know, serialVersionUID is only used for Serialization.
I get the UID to be 5165L for two completely different classes, which doesnt make sense, as I believe the UID is generated based on method and variable names in the class.
2 classes can have the same UID, the check is only on a "per class" basis.
You are mixing 2 things here: "manual" and "default" UID. When you manually set the UID, that's what the UID is. The UID must match when serializing. When you don't set it manually, a default value is define every time the class is modified.
That's the key point, by default your modified classes will never be compatible because the UID keep changing. When managing it manually, you decide when the changes impact the serialization.
* In so many words, serialVersionUID is used to apply versions on your classes and prevent the Serialization from proceeding in case of incompatibility (which could mess with your data??).