[jdom-interest] serialVersionUID

Jason Hunter jhunter at collab.net
Wed Sep 13 11:59:24 PDT 2000


> I think it is completely safe to stamp the above classes 
> ( except namespace of course) with a SVID.

OK, but let's be clear on the benefit we gain.  Per
http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/version.doc.html
it seems the SUID is a hash of the class name, fields, and methods.  So
if the methods are subject to change but not the variables then it's a
good idea to fix the SUID so serialization can occur between different
versions of the class that hold the same variable data.

Now, what happens when we add or remove a variable?  From 
http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/version.doc7.html
it looks like an added field will have its value set to the default on
deserialization of an old version, which will probably break the class. 
So at that point we'd have to manually regen the SUID.  A deleted field
(less likely in JDOM) would be ignored on deserialization of an old
version and that's just fine.

So is the proposal to assign the SUID now for beta5 with a note to
update it should we ever add a variable or perform any other action
listed at
http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/version.doc7.html?

-jh-



More information about the jdom-interest mailing list