Package: libgcj2 Version: 1:3.0.2-3 Severity: normal The implementation of ObjectInputStream.readObject() in this version of libgcj calls the constructor of the serialize object it is reading. Sun's implementation does not do this, nor (I think) did earlier versions of libgcj. Below is a sample program which prints "foo" once with javac, but twice with gcj/libgcj.
I found this while debugging a real program, where it was causing me quite a bit of confusion. -- Agthorr ------------------------------------------------------------------------ import java.io.*; class Break implements Serializable { int x; public Break () { System.err.println ("foo"); } static public void main (String [] args) throws java.io.IOException, java.lang.ClassNotFoundException { ByteArrayOutputStream bufout = new ByteArrayOutputStream (); ObjectOutputStream out = new ObjectOutputStream (bufout); Break foo = new Break (); foo.x = 5; out.writeObject (foo); byte [] bytes = bufout.toByteArray (); ByteArrayInputStream bufin = new ByteArrayInputStream (bytes); ObjectInputStream in = new ObjectInputStream (bufin); in.readObject (); } public String toString () {return Integer.toString (x);} } ------------------------------------------------------------------------ -- System Information Debian Release: testing/unstable Architecture: i386 Kernel: Linux eleutheromania 2.4.12 #1 Fri Oct 12 15:06:20 PDT 2001 i686 Locale: LANG=C, LC_CTYPE= Versions of packages libgcj2 depends on: ii libc6 2.2.4-5 GNU C Library: Shared libraries an ii libgcc1 1:3.0.2-3 GCC support library. ii zlib1g 1:1.1.3-16 compression library - runtime