[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH]
From: |
Bryce McKinlay |
Subject: |
Re: [PATCH] |
Date: |
Mon, 19 Nov 2001 13:05:54 +1300 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.5) Gecko/20011012 |
Dalibor Topic wrote:
--- classpath/java/io/Serializable.java Sat Nov 17 15:00:13 2001
+++ patched/java/io/Serializable.java Sat Nov 17 16:04:01 2001
@@ -40,6 +40,7 @@
*/
public interface Serializable
{
+ static final long serialVersionUID = 1196656838076753133L;
} // interface Serializable
This is redundant. An explicit serialVersionUID is only required when a
classes implementation may be different from the JDK version (different
private fields, for example), or where a class has evolved over time and
needs to be backward-compatible with serialized instances from the older
versions.
You can write your own simple serialver utility to verify this:
import java.io.*;
public class SerialVer
{
public static void main(String[] args) throws ClassNotFoundException
{
String className = args[0];
Class cl = Class.forName(className);
ObjectStreamClass osc = ObjectStreamClass.lookup(cl);
System.out.println (osc.getSerialVersionUID());
}
}
$ serialver java.io.Serializable
java.io.Serializable: static final long serialVersionUID =
1196656838076753133L;
$ gij SerialVer java.io.Serializable
1196656838076753133
regards,
Bryce.
- [PATCH], Dalibor Topic, 2001/11/18
- Re: [PATCH],
Bryce McKinlay <=