[kaffe] Serialization assignment of class handles

Mattias Rehnberg Mattias.Rehnberg at home.se
Sun Oct 31 09:44:03 PST 2004


When serializing a class like the one below, the second reference to Integer.class will be serialized using a handle to the first one. Sun's documentation states that the handle to the class should be assigned (and incremented) after the handle to the class descriptor has been assigned (and incremented), but it seems to be done the other way around now. This has the effect that when the object is deserialized (using the correct assignment order, which Kaffe does), class2 will refer to the class descriptor.

public class ClassRef implements Serializable {

    public Class class1 = Integer.class;
    public Class class2 = Integer.class;
    public ClassRef() {
    public String toString() {
        return "class 1 = " + this.class1 + ",  class2 = " + this.class1;

(A more common case would be objects with references to the same class writen to an object stream after each other.)


More information about the kaffe mailing list