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

SecurityException's new constructors force declaration of serialVersionUID

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • core-libs
    • sparc
    • solaris_2.6



      Name: ygR10224 Date: 05/30/2003


      Filed By : SPB JCK team (###@###.###)
      JDK : java full version "1.5.0-beta-b07"
      JCK : 1.5
      Platform[s] : Solaris
      switch/Mode :
      JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
      Failing Test [s] :
          api/java_lang/SecurityException/serial/index.html
          api/java_security/AccessControlException/serial/index.html
          api/java_lang/serialization/descriptions.html


      Problem description
      ===================
      Class java.lang.SecurityException does not define serialVersionUID.
      In jdk 1.5.0-beta-b07 due to fix of 4496095 (added 2 new constructors)
      the signature of this class was changed. As a result serialVersionUID
      was changed and causes the incompatibility with previous jdk builds.
      Field 'private static final long serialVersionUID' should be defined
      for this class with appropriate value 6878364983674394167L to avoid such
      incompatibility.


          
      Minimized test:
      ===============
      ------- TestSecurityException.java -------
      import java.io.*;

      public class TestSecurityException {
          
          public static void main(String args[]) {
              SecurityException se = new SecurityException();
              if (args[0].equals("write")) {
                  ObjectOutputStream stream = null;
                  try {
                      stream = new ObjectOutputStream(new FileOutputStream(args[1]));
                      stream.writeObject(se);
                      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]));
                      se = (SecurityException)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);
          }
          
      }
      ------- end-of-TestSecurityException.java -------

      Minimized test output:
      ======================
      <gyi@helmet(pts/3).259> /set/java/jdk1.4.2/solaris/bin/java -version
      java version "1.4.2-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-rc-b24)
      Java HotSpot(TM) Client VM (build 1.4.2-rc-b24, mixed mode)
      <gyi@helmet(pts/3).260> /set/java/jdk1.4.2/solaris/bin/java TestSecurityException write file.ser
      file.ser written successfully
      <gyi@helmet(pts/3).265> /set/java/jdk1.5.0/solaris/bin/java -version
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b07)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b07, mixed mode)
      <gyi@helmet(pts/3).263> /set/java/jdk1.5.0/solaris/bin/java TestSecurityException read file.ser
      Failed:java.io.InvalidClassException: java.lang.SecurityException; local class incompatible: stream classdesc serialVersionUID = 6878364983674394167, local class serialVersionUID = 870549591963010543


      JCK test source location:
      ==========================
      /java/re/jck/1.5//nightly/binaries/latest/JCK-runtime-15/tests

      Specific Machine Info:
      =====================
      SunOS helmet 5.8 Generic_108528-14 sun4u sparc SUNW,Ultra-2

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

            iris Iris Clark
            gyisunw Gyi Gyi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: