classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Why are serialVersionUIDs explicitly set in Exceptions?


From: Eric Arseneau
Subject: RE: Why are serialVersionUIDs explicitly set in Exceptions?
Date: Mon, 19 Feb 2001 16:29:26 -0800

> Does anybody know why we are explicitly setting the serialVersionUID
> on simple exceptions? I checked some classes by removing the
> explicit setting of the serialVersionUID and recompiling with jikes
> and gcj and the computed serialVersionUID was the same at the one
> set explicitly in the class. I checked ConcurrentModificationException,
> EmptyStackException, MissingResourceException, NoSuchElementException and
> TooManyListenersException, but a lot more classes explicitly set the
> serialVersionUID.
>
> Since the computed values are the same as the explicitly set ones
> I am wondering if we could not just remove them. It might hide bugs.
> What do people think about it?

You will find that for now the values may be the same, but if the algorithm
changes later, or use on a different VM that the result is not the same.
The reason for the UID is to identify an object uniquely regardless of VM,
library version or any other variable that could affect the computation of
the UID value.  So a first crack may be to let the environment produce one,
but then turn that out into an explicit set.  It is the only way to
guarantee that the value will always be the same.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]