Gillmer J. Derge [TeamB]
2006-02-28 04:42:54 UTC
Do any of you have a good technique that you like for maintaining
serialVersionUID in your classes? I usually tend to be fairly lazy
about it. I typically set it to 0L and forget about it forever, not
really keeping it up to date with changes in the class file. That works
in practice as long as you aren't saving objects in files (ex. if you
use serialization for RMI, EJB's, or something similar), but it's really
not the way it's supposed to work.
What I'd really like is something like an Ant task that would go through
my code looking for classes that implement Serializable. Whenever it
finds one, it should run serialver and update the source code with the
latest serialVersionUID value (which may or may not actually change the
source code, depending on whether the class has changed lately). I've
looked around a little, and I haven't found anything. I could maybe
write a simple shell script to do it, but like I said earlier, I tend to
be lazy about it.
The only alternatives I've come up with are:
a) remember to run update the serialVersionUID manually every time you
change the class. My memory is good but not that good.
b) Put something into your checkin or deployment procedure that reminds
you to manually update every class. That works, but as soon as you have
more than about 3 serializable classes it's kind of ridiculous.
serialVersionUID in your classes? I usually tend to be fairly lazy
about it. I typically set it to 0L and forget about it forever, not
really keeping it up to date with changes in the class file. That works
in practice as long as you aren't saving objects in files (ex. if you
use serialization for RMI, EJB's, or something similar), but it's really
not the way it's supposed to work.
What I'd really like is something like an Ant task that would go through
my code looking for classes that implement Serializable. Whenever it
finds one, it should run serialver and update the source code with the
latest serialVersionUID value (which may or may not actually change the
source code, depending on whether the class has changed lately). I've
looked around a little, and I haven't found anything. I could maybe
write a simple shell script to do it, but like I said earlier, I tend to
be lazy about it.
The only alternatives I've come up with are:
a) remember to run update the serialVersionUID manually every time you
change the class. My memory is good but not that good.
b) Put something into your checkin or deployment procedure that reminds
you to manually update every class. That works, but as soon as you have
more than about 3 serializable classes it's kind of ridiculous.
--
Gillmer J. Derge [TeamB]
Gillmer J. Derge [TeamB]