java - Why use random numbers for serial version UID? -
this question has reply here:
why generate long serialversionuid instead of simple 1l? 9 answersedit: random mean big computed number no semantic meaning developers
when implementing serializable interface best practice , of import specify serial version uid. in numerous places, see random numbers beingness used. e.g.
effective java (2nd edition) pg 312:
private static final long serialversionuid = 234098243823485285l;
from string class in java 6:
private static final long serialversionuid = -6849794470754667710l;
from arraylist class in java 6:
private static final long serialversionuid = 8683452581122892189l;
etc. eclipse offers alternative generate these random numbers (though primary default appears to generate serialversionuid of 1l
)
why utilize random numbers? doesn't create more sense start @ 1l , increment 2l when changes sensible revision control? time can think of utilize seemingly random number if didn't specify serialversionuid begin , want (which ties in run-time autogenerated version provide backwards compatibility support).
those "random" numbers numbers would have been generated class automatically in "current" form per java object serialization specification... "current" "current @ time serialversionuid
first declared".
that allow info had been serialized still deserialized - while moving forwards more explicit declaration of breaking changes in future.
java serialization
No comments:
Post a Comment