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

BeanContextSupport is incorrectly deserializaed in kestrel

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      kestrel
    • CPU:
      sparc
    • OS:
      solaris_7
    • Verification:
      Verified

      Description



      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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: