Serialization problem

Date view Thread view Subject view Author view

From: NADIA VIEIRA LEAO PEREIRA (972155@dcc.unicamp.br)
Date: Sat Nov 21 1998 - 14:59:57 EST


Hello!

I've just fixed a bug in java.io.ObjectInputStream, that would cause
it to endless loop, but now I've met another problem that I don't know
how to fix.

[[ snip ... snip ]]

The failing test program is:

---> cut here <---
import java.util.Hashtable;
import java.io.*;

public class TesteHash {

    public static void main(String[] args){

        try{
            File file = new File("Hashtable.txt");
            FileOutputStream fos = new FileOutputStream( file ); //excecão: IOException
            ObjectOutputStream oos = new ObjectOutputStream(fos); //excecão: IOException

            oos.writeObject( new Hashtable() );

            fos.close();

            FileInputStream fis = new FileInputStream(file); //excecão: FileNotFoundException
            ObjectInputStream ois = new ObjectInputStream(fis); //excecões: StreamCorruptedException, IOException

            Hashtable hash = (Hashtable) ois.readObject();

            fis.close();

        } catch(Exception ioe){
            System.out.println("ioexception: "+ ioe.getMessage());
            ioe.printStackTrace();
        }
    }

}
---> cut here <---

And the error is:

ioexception: null
java.io.EOFException
        at java/lang/Throwable.<init>(31)
        at java/lang/Exception.<init>(17)
        at java/io/IOException.<init>(17)
        at java/io/EOFException.<init>(17)
        at java/io/ObjectInputStream.readWithEOF(445)
        at java/io/ObjectInputStream.readShort(170)
        at java/io/ObjectStreamClass.readObject(140)
        at java/io/ObjectInputStream.readObject(219)
        at TesteHash.main(21)

I'm using a very recently checked-out CVS tree.

Thanks in advance for any help.

-- 
Nadia

----- End of forwarded message from NADIA VIEIRA LEAO PEREIRA ----- ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:04 EDT