Eclipse nicely generates the serialVersionUID for me. But this seems to be passive code generation as the id won\'t be automatically updated as I change the file unless I do
There is no standard functionality in Eclipse to do this.
You could update the serial version at build time with the Ant SerialVer task.
the id won't be automatically updated as I change the file unless I do the generation again.
AFAIK default serialVersionUID
is just this -- an id generated based on current "shape" of a class. So if you want your id generated when you change anything -- just leave it out.
However, if you want to change serialVersionUID
only sometimes -- just change it. Random modification to the id will do.
Random number is only little better than consecutive numbers (if you can assume no one else makes up a class with the same qualified name in your environment), so you may even start from serialVersionUID = 1
and increment this number at will.