Dr Andrew John Hughes wrote:
On 16:43 Thu 25 Aug , joe.da...@oracle.com wrote:
Changeset: 624cc18a6cf9
Author: darcy
Date: 2011-08-25 09:42 -0700
URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/624cc18a6cf9
7082727: VirtualMachineError should declare its serialVersionUID
Reviewed-by: alanb
! src/share/classes/java/lang/VirtualMachineError.java
Is there a general policy on serialVersionUIDs within the JDK i.e. that they
are declared?
I've seen a few warnings during builds, and I'm wondering what the correct fix
is in the
majority of cases.
What the policy *should* be is roughly "all serializable classes that
are exported API should declare serialVersionUIDs." There could be
exceptions to this in awt (or is it swing?) where some classes are
declared serializable but are only intended to be written and read by
the same release as opposed to across releases. This policy can be
enforced by changing the build to include "javac -Xlint:serial
-Werror". Additionally, for the classes that are supposed to be
serializable across platforms, the values of the serialVersionUIDs
should be tracked too.
If a class doesn't already have a serialialVersionUID, the correct fix
is usually to declare an explicit serialVersionUID which matches the
computed serialVersionUID in the first platform release the class was
introduced.
-Joe