Hi, The current ObjectInputStream/ObjectOutputStream implementation doesn't support multiple private fields with the same name.
Example:
import java.io.*;
class sertestbase implements Serializable {
private int a = 1;
public String toString() { return "" + a; }
}
class sertest extends sertestbase {
private int a = 2;
public static void main(String[] args) throws Throwable {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ObjectOutputStream(baos).writeObject(new sertest());
ByteArrayInputStream bais = new
ByteArrayInputStream(baos.toByteArray());
Object o = new ObjectInputStream(bais).readObject();
System.out.println(o);
}
public String toString() {
return "" + a + ", base: " + super.toString();
}
}
Attached is a patch for java/io/ObjectInputStream.java and
java/io/ObjectOutputStream.java, I haven't patched the native code (I
don't use it), but the change should be trivial.
Regards,
Jeroen
ser.patch
Description: Binary data

