-
Bug
-
Resolution: Fixed
-
P5
-
1.1.3, 1.2.0, 1.2.1, 1.2.2, 1.3.0
-
beta
-
generic, x86, sparc
-
generic, solaris_2.5.1, solaris_7, windows_nt
-
Verified
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)
======================================================================
- duplicates
-
JDK-4264920 Bug in reflection/serialization combination with primitive types
-
- Closed
-
-
JDK-4339184 Failure to find int.class on de-serialization
-
- Closed
-
- relates to
-
JDK-4662491 ObjectInputStream.resolveClass() javadoc doesn't mention primitive types
-
- Resolved
-
-
JDK-4442373 MarshalInputStream cannot resolve primitive classes
-
- Closed
-
-
JDK-4519050 cannot deserialize void.class
-
- Closed
-