Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4243976

java.io.Filepermission is s`wrong serialized in Kestrel-F

XMLWordPrintable

    • beta
    • generic, sparc
    • generic, solaris_2.5.1



      Name: avC70361 Date: 06/04/99



        java.io.FilePermission is incorrectly deserialized in kestrel when has been serialized in jdk1.2.
      The exception "java.io.InvalidClassException: java.io.FilePermission; Local class not compatible:
      stream classdesc serialVersionUID=7930732926638008763 local class serialVersionUID=-6327574901970006797" is
      thrown.

      Here is a 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);

        }

      }
      -----------The test output---------
      jdk 1.2:

      <avv@mizar(pts/3).367> java -version
      java version "1.2"
      Classic VM (build JDK-1.2-V, green threads, sunwjit)
      <avv@mizar(pts/3).368> java FilePermissionTest write
      FilePermission written successfully
      <avv@mizar(pts/3).369> java FilePermissionTest read
      Passed

      Kestrel:

      <avv@mizar(pts/3).371> java FilePermissionTest read
      Failed:java.io.InvalidClassException: java.io.FilePermission; Local class not compatible: stream classdesc serialVersionUID=7930732926638008763 local class serialVersionUID=-6327574901970006797

      ======================================================================

            jlueheorcl Jan Luehe (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: