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

BeanContextSupport is incorrectly deserializaed in kestrel

    • kestrel
    • sparc
    • solaris_7
    • Verified



      Name: avC70361 Date: 10/20/99



        The java.beans.beancontext.BeanContextSupport is incorrectly deserialized
      in kestrel if it has been serialized in jdk 1.2.

      Here is a test demonstrating the bug.
      ----------BeanContextSupportTest.java-------
      import java.beans.beancontext.*;
      import java.io.*;

      public class BeanContextSupportTest {

        public static void main(String args[]) {

          BeanContextSupport bcs = new BeanContextSupport();

          if (args[0].equals("write")) {

            ObjectOutputStream stream = null;

            try {

              stream = new ObjectOutputStream(new FileOutputStream(args[1]));
              stream.writeObject(bcs);
              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]));
              bcs = (BeanContextSupport)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----------
      <avv@mozart(pts/3).485> jdk 1.2
      <avv@mozart(pts/3).486> java -version
      java version "1.2"
      Classic VM (build JDK-1.2-V, green threads, sunwjit)
      <avv@mozart(pts/3).487> java BeanContextSupportTest write file.ser
      file.ser written successfully
      <avv@mozart(pts/3).488> java BeanContextSupportTest read file.ser
      Passed
      <avv@mozart(pts/3).489> jdk 1.3
      <avv@mozart(pts/3).490> java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-K)
      Java HotSpot (TM) Client VM (build 1.3-K, interpreted mode)
      <avv@mozart(pts/3).491> java BeanContextSupportTest read file.ser
      Failed:java.io.InvalidClassException: java.beans.beancontext.BeanContextSupport; Local class not compatible: stream classdesc serialVersionUID=-4879613978649577204 local class serialVersionUID=4976122088882138962

      ======================================================================
      mark.davidson@Eng 1999-11-15

          [JDK-4282900] BeanContextSupport is incorrectly deserializaed in kestrel

          BT2:CONVERTED DATA

          BugTraq+ Release Management Values

          COMMIT TO FIX:
          generic
          kestrel

          FIXED IN:
          kestrel

          INTEGRATED IN:
          kestrel

          VERIFIED IN:
          kestrel

          Defect Conversion BT2 (Inactive) added a comment - BT2:CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic kestrel FIXED IN: kestrel INTEGRATED IN: kestrel VERIFIED IN: kestrel

          BT2:EVALUATION

          This incompatibility in the serialization was introduced in version 1.33 of BeanContextSupport.java. A new method was added which broke the serialVersionUID compatibilty. There were probably other serialization incompatibilities between versions of other classes and I'm not sure why this isn't being picked up.

          A workaround would be to add the serialVersionUID of the old class to the new class but I'm not going to do it since this class isn't used so much.

          Will not fix.

          mark.davidson@Eng 1999-11-04

          ###@###.### 1999-11-09
          This bug causes JCK Kestrel tests failures:
          api/java_beans/beancontext/serialization/descriptions.html#BeanContextSupport
          api/java_beans/beancontext/serialization/descriptions.html#BnContextMembrshpEvt
          These are old JCK tests. In JCK 1.2 these tests pass.
          So, this bug needs a fix.

          Defect Conversion BT2 (Inactive) added a comment - BT2:EVALUATION This incompatibility in the serialization was introduced in version 1.33 of BeanContextSupport.java. A new method was added which broke the serialVersionUID compatibilty. There were probably other serialization incompatibilities between versions of other classes and I'm not sure why this isn't being picked up. A workaround would be to add the serialVersionUID of the old class to the new class but I'm not going to do it since this class isn't used so much. Will not fix. mark.davidson@Eng 1999-11-04 ###@###.### 1999-11-09 This bug causes JCK Kestrel tests failures: api/java_beans/beancontext/serialization/descriptions.html#BeanContextSupport api/java_beans/beancontext/serialization/descriptions.html#BnContextMembrshpEvt These are old JCK tests. In JCK 1.2 these tests pass. So, this bug needs a fix.

          BT2:PUBLIC COMMENTS

          Added servialVersionUID from 1.2 class for backwards compatibility
          mark.davidson@Eng 1999-11-15

          Mark Davidson (Inactive) added a comment - BT2:PUBLIC COMMENTS Added servialVersionUID from 1.2 class for backwards compatibility mark.davidson@Eng 1999-11-15

            mdavidsosunw Mark Davidson (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: