Search code examples
javaserializationserialversionuid

What content does getSerialVersionUID use to determine the UID?


So, I have a large project that serializes many things when saving a configuration, and had to do a re-design of a large section of it. Since I had already defined the serialVersionUID field for a lot of classes, I wanted to know which files I needed to re-calculate the UID for.

I couldn't find any post on SO about what properties of a class were used in the calculation of the serialVersionUID (via ObjectStreamClass.lookup(classname) ). I finally found the spot in the spec that defines it. So, this is more of one of those self-answering questions for the sake of saving this small piece of knowledge.

If this is out-of-etiquette (since it is a spec question) please let me know, I'll gladly remove it or whatever is SO-appropriate.

So, what particulars of a class are used when using the Java-built-in algorithm of calculating a serialVersionUID?


Solution

  • It's detailed right here in the Java spec!

    http://docs.oracle.com/javase/6/docs/platform/serialization/spec/class.html#4100

    Does anybody know if it's different based on different implementations/utilities? (Such as via ObjectStreamClass.lookup vs. serialver utility?)