-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
1.2.0
-
sparc
-
solaris_2.5
Name: avC70361 Date: 05/14/98
The java.io.FilePermission is incorrectly deserialized in jdk1.2beta4E when
it has been serialized in jkd1.2-beta3. The InvalidClassException is thrown due
to local class incompatibility.
Here is the test demonstrating the bug.
-------------FilePermissionTest.java------------
import java.io.*;
public class FilePermissionTest {
public static void main(String args[]) {
FilePermission filePermission;
String filepath = "FilePermission.ser";
if (args[0].equals("write")) {
filePermission = new FilePermission("path", "read");
ObjectOutputStream stream = null;
try {
stream = new ObjectOutputStream(new FileOutputStream(filepath));
stream.writeObject(filePermission);
stream.close();
} catch(IOException e) {
System.out.println("Couldn't write to " + filepath + " : " + e);
System.exit(1);
}
System.out.println("FilePermission written successfully");
} else if (args[0].equals("read")) {
ObjectInputStream stream = null;
try {
stream = new ObjectInputStream(new FileInputStream(filepath));
filePermission = (FilePermission)stream.readObject();
} catch(InvalidClassException e) {
System.out.println("Failed:" + e);
System.exit(1);
} catch(Exception e) {
System.out.println(
"Failed: couldn't read from" + filepath + " : " + e
);
System.exit(1);
}
System.out.println("Passed");
}
System.exit(0);
}
}
----------------Test output----------
On jdk1.2-beta3:
<avv@stardust(pts/24).263> java -fullversion
java full version "JDK-1.2beta3-N"
<avv@stardust(pts/24).265> java FilePermissionTest write file.ser
FilePermission written successfully
<avv@stardust(pts/24).266> java FilePermissionTest read file.ser
Passed
On jdk1.2-beta4:
<avv@stardust(pts/2).538> java -fullversion
java full version "JDK-1.2beta4-E"
<avv@stardust(pts/2).539> java FilePermissionTest read file.ser
Failed:java.io.InvalidClassException: java.io.FilePermission; Local class not compatible: stream classdesc serialVersionUID=-3107630564271172646 local class serialVersionUID=1578790672454573808
======================================================================