From: Alexandre Oliva (oliva@dcc.unicamp.br)
Date: Tue Dec 01 1998 - 12:01:45 EST
Hi!
Nadia could not find again that other serialization problem I
mentioned, but Alexandre Braga found another problem. I'll be
overloaded till next week, and then I hope I'll be able to get back to
software development :-)
Hope this helps...
--
Alexandre Oliva http://www.dcc.unicamp.br/~oliva aoliva@{acm.org}
oliva@{dcc.unicamp.br,gnu.org,egcs.cygnus.com,samba.org}
Universidade Estadual de Campinas, SP, Brasil
------- Start of forwarded message -------
Date: Tue, 1 Dec 1998 14:47:38 -0200 ( )
From: ALEXANDRE MELO BRAGA <972314@dcc.unicamp.br>
To: Alexandre Oliva <oliva@dcc.unicamp.br>
Subject: bug do kaffe
Message-ID: <Pine.GSO.4.05.9812011440450.16671-100000@iguacu.dcc.unicamp.br>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
/*
This program tries to serialize and to unserialize a string, a byte
array and a Byte. It works well only for the first case. Class
Serializer is just a wrapper for the serialization and deserialization
operations.
*/
import java.io.*;
class Serializer {
public static byte[] serialize(Serializable object){
ByteArrayOutputStream bArrayOut = null;
try{
bArrayOut = new ByteArrayOutputStream();
ObjectOutput objOut = new ObjectOutputStream(bArrayOut);
objOut.writeObject(object);
objOut.flush();
objOut.close();
} catch (Exception e){ e.printStackTrace();}
return(bArrayOut.toByteArray());
}
public static Serializable unserialize(byte[] serializedObject){
Serializable object = null;
try{
ObjectInput objIn = new ObjectInputStream(new ByteArrayInputStream(serializedObject));
object = (Serializable) objIn.readObject();
objIn.close();
} catch (Exception e){ e.printStackTrace();}
return(object);
}
}
public class BugFoundout{
public static void main(String[] argv){
//this case works well!
System.out.println(Serializer.unserialize(Serializer.serialize(new String("this is a test"))));
//these two do not work!
System.out.println(Serializer.unserialize(Serializer.serialize(new byte[]{(byte)0})));
System.out.println(Serializer.unserialize(Serializer.serialize(new Byte((byte)0))));
}
}
------- End of forwarded message -------
This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:04 EDT