Kaffe serialVersionUID bug?
Stuart Ballard
kaffe@rufus.w3.org
Thu, 29 Jun 2000 12:58:04 -0400
This is a multi-part message in MIME format.
--------------62F6E64594113BB6A348B9D1
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Attaching a patch to fix all the serialVersionUIDs that were public. (I
think you need to be in libraries/javalib to apply it - sorry; my first
ever cvs diff)
Can anyone explain to me why some *interfaces* had serialVersionUIDs?
That doesn't make sense to me. My patch comments them out, although if
they really are incorrect they should be removed completely.
Anyway, I've done some debugging of the ObjectStreamClass issue, and it
turns out that Kaffe is accepting a serialVersionUID field defined in a
superclass as a serialVersionUID for a given class, even if that field
is private.
The code that's responsible for this is in
clib/native/ObjectStreamClassImpl.c starting at line 491 and looks like
this:
fld = lookupClassField(cls, serialVersionUIDName, true, &einfo);
if (fld != 0 /**/ && (fld->accflags & (ACC_STATIC|ACC_FINAL)) ==
(ACC_STATIC|ACC_FINAL)) {
return (*(jlong*)FIELD_ADDRESS((Field*)fld));
} else {
discardErrorInfo(&einfo);
}
I've inserted /**/ where I believe a fix could go - something like
&& fld->type == cls
sounds right to me although I don't know if == can be used to compare an
Hjava_lang_Class object. When I actually made this change I got a
NullPointer, which doesn't make much sense to me.
I think that lookupClassField might also have a problem, although I'm
not so sure on this one. A private field in a superclass should never be
accessible to subclasses - so why is lookupClassField returning one?
This doesn't eliminate the need for the first fix, because even if the
serialVersionUID of a superclass *is* accessible, it shouldn't be used.
If someone could take a look at these issues and see if my guesses are
right or completely screwy, I'd be very grateful.
Thanks,
Stuart.
--------------62F6E64594113BB6A348B9D1
Content-Type: text/plain; charset=us-ascii;
name="kaffe.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="kaffe.diff"
Index: java/io/IOException.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/io/IOException.java,v
retrieving revision 1.3
diff -u -r1.3 IOException.java
--- java/io/IOException.java 1999/10/12 02:29:46 1.3
+++ java/io/IOException.java 2000/06/29 16:29:35
@@ -15,7 +15,7 @@
extends Exception
{
-public static final long serialVersionUID = 7818375828146090155l;
+private static final long serialVersionUID = 7818375828146090155l;
public IOException () {
super();
Index: java/io/InvalidClassException.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/io/InvalidClassException.java,v
retrieving revision 1.4
diff -u -r1.4 InvalidClassException.java
--- java/io/InvalidClassException.java 2000/06/16 11:13:40 1.4
+++ java/io/InvalidClassException.java 2000/06/29 16:29:35
@@ -15,7 +15,7 @@
extends ObjectStreamException
{
-public static final long serialVersionUID = -4333316296251054416L;
+private static final long serialVersionUID = -4333316296251054416L;
public String classname;
Index: java/io/Serializable.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/io/Serializable.java,v
retrieving revision 1.2
diff -u -r1.2 Serializable.java
--- java/io/Serializable.java 1999/03/24 01:14:44 1.2
+++ java/io/Serializable.java 2000/06/29 16:29:35
@@ -11,5 +11,6 @@
package java.io;
public interface Serializable {
- static final long serialVersionUID = 1196656838076753133L;
+// I'm almost certain that interfaces can't have SVUIDs
+// static final long serialVersionUID = 1196656838076753133L;
}
Index: java/lang/Exception.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/lang/Exception.java,v
retrieving revision 1.2
diff -u -r1.2 Exception.java
--- java/lang/Exception.java 1999/10/12 02:29:47 1.2
+++ java/lang/Exception.java 2000/06/29 16:29:35
@@ -14,7 +14,7 @@
extends Throwable
{
-public static final long serialVersionUID = -3387516993124229948l;
+private static final long serialVersionUID = -3387516993124229948l;
public Exception () {
super();
Index: java/lang/String.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/lang/String.java,v
retrieving revision 1.30
diff -u -r1.30 String.java
--- java/lang/String.java 2000/04/06 17:58:03 1.30
+++ java/lang/String.java 2000/06/29 16:29:36
@@ -38,7 +38,7 @@
int hash;
/* This is what Sun's JDK1.1 "serialver java.lang.String" spits out */
- static final long serialVersionUID = -6849794470754667710L;
+ private static final long serialVersionUID = -6849794470754667710L;
public static final Comparator CASE_INSENSITIVE_ORDER = new ICComp();
Index: java/security/Key.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/security/Key.java,v
retrieving revision 1.1
diff -u -r1.1 Key.java
--- java/security/Key.java 1999/10/15 01:12:14 1.1
+++ java/security/Key.java 2000/06/29 16:29:36
@@ -19,7 +19,8 @@
public interface Key extends Serializable {
- public static final long serialVersionUID = 6603384152749567654L;
+// I'm almost certain interfaces can't have SVUIDs
+// static final long serialVersionUID = 6603384152749567654L;
public String getAlgorithm();
public String getFormat();
Index: java/security/PrivateKey.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/security/PrivateKey.java,v
retrieving revision 1.1
diff -u -r1.1 PrivateKey.java
--- java/security/PrivateKey.java 1999/10/15 01:12:15 1.1
+++ java/security/PrivateKey.java 2000/06/29 16:29:36
@@ -17,7 +17,8 @@
public interface PrivateKey extends Key {
- public static final long serialVersionUID = 6034044314589513430L;
+// I'm almost certain that interfaces can't have SVUIDs
+// static final long serialVersionUID = 6034044314589513430L;
}
Index: java/security/PublicKey.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/security/PublicKey.java,v
retrieving revision 1.1
diff -u -r1.1 PublicKey.java
--- java/security/PublicKey.java 1999/10/15 01:12:15 1.1
+++ java/security/PublicKey.java 2000/06/29 16:29:36
@@ -17,7 +17,8 @@
public interface PublicKey extends Key {
- public static final long serialVersionUID = 7187392471159151072L;
+// I'm almost certain that interfaces can't have SVUIDs
+// public static final long serialVersionUID = 7187392471159151072L;
}
--------------62F6E64594113BB6A348B9D1--