-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
1.2fcs
-
sparc
-
solaris_2.4, solaris_2.5
-
Verified
Name: avC70361 Date: 05/14/98
The java.lang.reflect.InvocationTargetException is incorrectly deserialized in
jdk1.2-beta4 when have been serialized in jdk1.1.6. The exception
InvalidClassException is thrown
Here is the test demonstarating the bug.
--------------InvocationTargetExceptionTest.java--------
import java.io.*;
import java.lang.reflect.InvocationTargetException;
public class InvocationTargetExceptionTest {
public static void main(String args[]) {
InvocationTargetException exception = new InvocationTargetException(
new Exception("")
);
if (args[0].equals("write")) {
ObjectOutputStream stream = null;
try {
stream = new ObjectOutputStream(new FileOutputStream(args[1]));
stream.writeObject(exception);
stream.close();
} catch(IOException e) {
System.out.println("Couldn't write to " + args[1] + " : " + e);
System.exit(1);
}
System.out.println(args[1] + " written successfully");
} else if (args[0].equals("read")) {
ObjectInputStream stream = null;
try {
stream = new ObjectInputStream(new FileInputStream(args[1]));
exception = (InvocationTargetException)stream.readObject();
} catch(InvalidClassException e) {
System.out.println("Failed:" + e);
System.exit(1);
} catch(Exception e) {
System.out.println(
"Failed: couldn't read from" + args[1] + " : " + e
);
System.exit(1);
}
System.out.println("Passed");
}
System.exit(0);
}
}
-------------The test output-----------
Under jdk1.1.6:
<avv@stardust(pts/24).286> java -fullversion
java full version "JDK1.1.6N"
<avv@stardust(pts/24).287> java InvocationTargetExceptionTest write file.ser
file.ser written successfully
<avv@stardust(pts/24).288> java InvocationTargetExceptionTest read file.ser
Passed
Under jdk1.2beta4:
<avv@stardust(pts/2).554> java -fullversion
java full version "JDK-1.2beta4-E"
<avv@stardust(pts/2).555> java InvocationTargetExceptionTest read file.ser
Failed:java.io.InvalidClassException: java.lang.reflect.InvocationTargetException; Local class not compatible: stream classdesc serialVersionUID=4085088731926701167 local class serialVersionUID=890867112645259490
======================================================================
- duplicates
-
JDK-4147482 The serializable class java.lang.reflect.InvocationTargetException evolved incom
- Closed