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

default serialVersionUID changed due to change in class literal handling

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.2
    • 1.4.2
    • tools
    • None
    • mantis
    • generic
    • generic

      This regression test fails in the current mantis TL integration workspace due to
      changes in the compiler for class literals:

        java/io/Serializable/defaulted/GetFieldWrite.java

      OUTPUT:

      java.io.InvalidClassException: TestClass; local class incompatible: stream classdesc serialVersionUID = 618679675890498946, local class serialVersionUID = 5748652654655279289
              at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:459)
              at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
              at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
              at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
              at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
              at GetFieldRead.main(GetFieldRead.java:85)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:324)
              at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94)
              at java.lang.Thread.run(Thread.java:536)

      jdis of declared fields in GetFieldRead.TestClasses:

      1.4.2-beta-b01 (test passes):

        public static final Field DEFAULT_OBJECT_I:"Ljava/lang/Integer;";
        private static final Field serialVersionUID:J = long 1301210429009902690l;
        private static final Field
           serialPersistentFields:"[Ljava/io/ObjectStreamField;";
        Field objectI:"Ljava/lang/Integer;";
        static synthetic Field class$java$lang$Integer:"Ljava/lang/Class;";

      TL integration workspace (test fails):

        public static final Field DEFAULT_OBJECT_I:"Ljava/lang/Integer;";
        private static final Field serialVersionUID:J = long 1301210429009902690l;
        private static final Field
          serialPersistentFields:"[Ljava/io/ObjectStreamField;";
        Field objectI:"Ljava/lang/Integer;";

      GetFieldRead.TestClass contains class literals which cause the creation of an
      anonymous class. It used to be that a static synthetic field was generated.

      Serialization looks at the static synthetic field. The problem
      will impact any top-level class which currently does not declare a
      serialVersionUID and uses class literals. Of particular note, any top-level
      class which declares serialPersistentFields will likely run into this problem
      as the recommended paradigm uses class literals.

      Class literal handling appears to have changed as a result of fixes to these
      bugs:

        4401576: Using a class literal causes outermost class to be initialized
          early
        4468823: class literal causes the referenced class to be initialized

      Minimally, the serialVersionUID needs to be updated in GetFieldRead (not
      GetFieldWrite) so that any other changes in the serialVersionUID computation
      are detected. We also need to verify that the JDK source always declares the
      serialVersionUID as necessary.

      -- iag@sfbay 2002-08-20

            gafter Neal Gafter (Inactive)
            iris Iris Clark
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: