geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zakharov, Vasily M" <>
Subject RE: Standard for serialVersionUID
Date Thu, 31 Aug 2006 14:01:21 GMT

Adding serialVersionUIDs to Serializable classes is sure a great idea!
It's strongly recommended by Sun, and all the way helps when dealing
with serialization in large projects.

It's not in fact important what particular value you specify for
serialVersionUID field, the only thing important is you change the
serialVersionUID for a class when its serialized form changes, and ONLY
if its serialized form changes. From this perspective, using class
version number is not a good idea, as a class may be modified (and thus
version number changed), but a serialized form may stay the same, and
changing serialVersionUID would introduce an unnecessary serialization

The traditional way is to use 'serialver' program from Sun's JDK. If
this way is for some reason uncomfortable for you, you may use some
other way to calculate serialVersionUIDs, like Eclipse built-in feature
or the like. The particular value is not important, only changes to it

Note however, that small values like 1 or 2 are traditionally used as
serialVersionUIDs for synthetic and other system classes, like Enums and
RMI Stubs, that are serialized in a special way. So using such values in
"normal" classes may confuse the future readers of the code and make
them wonder if that particular class is serialized in a special way. So
I'm suggesting using traditional (20-digit or so) values for

Thank you!

Vasily Zakharov
Intel Middleware Products Division

-----Original Message-----
From: Heinz Drews [] 
Sent: Thursday, August 31, 2006 9:46 AM
To: geronimo-dev
Subject: Standard for serialVersionUID

As I have mentioned in another message I have accidently used class
files in modules created by Eclipse embeded compiler.  This calculates
serialVersionUID different way then javac.

I think that adding serialVersionUID to all serializable class would
address the situation best.
There are quite a number of class without the uid.  I would volunteer
to add them but which standard should be used?

Eclipse provides the option set it to 1 or  to calculate the uid. But
the calculation is different to the one doen by javac.

In other projects I have found the convention to use version number to
support detection of incompatible modifications.  The version number a
much nicer to read in the message reporting mismatches than the
generated ones.

Least impact would be to calculate the value with the serialver tool.
This avoids the need for redeploying.

Which standard should be chosen?


View raw message