| Other |
|---|
| 1.4.0 betaFixed |
|
Duplicate :
|
|
|
Duplicate :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
Name: rm29839 Date: 09/03/98
package jp.go.etl.takagi.test.bug_deserializing_class_of_primitive_type;
import java.io.*;
public class Test {
public static void main(String[] args) throws Exception {
PipedOutputStream os = new PipedOutputStream();
InputStream is = new PipedInputStream(os);
ObjectOutput oo = new ObjectOutputStream(os);
ObjectInput oi = new ObjectInputStream(is);
oo.writeObject(Integer.class);
System.out.println(oi.readObject());
oo.writeObject(int.class);
System.out.println(oi.readObject());
}
}
> java jp.go.etl.takagi.test.bug_deserializing_class_of_primitive_type.Test
class java.lang.Integer
java.lang.ClassNotFoundException: int
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:352)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:233)
at jp.go.etl.takagi.test.bug_deserializing_class_of_primitive_type.Test.main(Test.java:12)
(Review ID: 34926)
======================================================================
Name: skT88420 Date: 09/14/99
Consider the following example:
import java.io.*;
import java.util.*;
public class Serial implements Serializable {
Class cl = int.class;
public static void main(String[] args){
try {
FileOutputStream out = new FileOutputStream("tmp");
ObjectOutputStream ous = new ObjectOutputStream(out);
ous.writeObject(new Serial());
ous.close();
FileInputStream in = new FileInputStream("tmp");
ObjectInputStream ins = new ObjectInputStream(in);
Serial s = (Serial)ins.readObject();
ins.close();
} catch (Throwable e) {
System.out.println(e);
}
}
}
when run, it produces the following results:
J:\borsotti\jtest>java Serial
java.lang.ClassNotFoundException: int
The same problem occurs if the value of the serializable
field is another primitive class, like e.g. double, void, etc.
(Review ID: 95240)
======================================================================
|