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

Serialization for java.awt.ScrollPane causes compatibility problem

    XMLWordPrintable

Details

    Description



      Name: ooR10001 Date: 04/13/2001


      Serialization for java.awt.ScrollPane causes compatibility problem because
      instance of SrollPane, serialized under jdk version older than 1.4, incorrectly
      deserialized under jdk1.4.

      Following minimized test shows the bug:

      This code compiled and executed under jdk1.3.
      Result is creating 'test.ser' file and print the value of scrollbarDisplayPolicy
      ----------------------------
      import java.awt.ScrollPane;

      public class t {

        public static void main(String[] args) {
           try {
                java.io.FileOutputStream fos =
                        new java.io.FileOutputStream("test.ser");
                java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(fos);
                ScrollPane sp = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
                System.out.println("Serialized display policy is: "
                                   + sp.getScrollbarDisplayPolicy());
                oos.writeObject(sp);
                oos.close();
                fos.close();
            } catch (java.io.IOException e) {
                e.printStackTrace();
            }
        }
      }
      ----------------------------

      Output:
      -------------
      Serialized display policy is: 1
      -------------

      This code compiled under jdk1.4.
      Result is deserialising ScrollPane instance from 'test.ser' file
      and print the value of deserialized scrollbarDisplayPolicy.

      ----------------------------
      import java.awt.ScrollPane;

      public class t {

        public static void main(String[] args) {
            try {
                java.io.FileInputStream fis =
                        new java.io.FileInputStream("test.ser");
                java.io.ObjectInputStream ois = new java.io.ObjectInputStream(fis);
                ScrollPane x = (ScrollPane)ois.readObject();
                System.out.println("Deserialized display policy is: "
                                   + x.getScrollbarDisplayPolicy());
                ois.close();
                fis.close();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (java.io.IOException e) {
                e.printStackTrace();
      }
            }
      }
      ----------------------------

      Output:
      ---------------
      Deserialized display policy is: 0
      ---------------

      This is a crossversion compatibility problem. It needs to be fixed.

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

      Attachments

        Issue Links

          Activity

            People

              mwarressunw Michael Warres (Inactive)
              oovsunw Oov Oov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: