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

java.awt.TextArea desrialized wrong under jdk1.2

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2.2
    • CPU:
      x86, sparc
    • OS:
      solaris_2.5, windows_2000

      Description



      Name: avC70361 Date: 10/01/98



        The java.awt.TextArea instance serialized in jdk 1.1.6 is incorectly deserialized in jdk1.2.
      In jdk 1.1.6 the constructor accepts all possible values for the scrollbarVisibility parameter,
      but in jdk1.2 the constructor tests if the parameter is legal and corrects it if needed. But
      this check is not performed during deserialization and if the scrollbarVisibility field has
      been set to an illegal value in jdk1.1.6, serialized and deserialized in jdk1.2, the field will
      have an illegal value.

      Here is a test demonstrating the bug
      --------------TextAreaTest.java-------------
      import java.awt.TextArea;
      import java.io.*;

      public class TextAreaTest {

        public static void main(String args[]) {
          TextArea area = new TextArea("area", 40, 60, 5/* an illegal value*/);

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

            try {

              FileOutputStream fos = new FileOutputStream(args[1]);
              ObjectOutputStream ostream = new ObjectOutputStream(fos);

              ostream.writeObject(area);
              ostream.flush();
              fos.close();

              System.out.println(args[1] + " is successfuly created");

            } catch(IOException e) {
              System.out.println("Unexpected exception : " + e);
            }

          } else if (args[0].equals("read")) {

            try {

              FileInputStream fis = new FileInputStream(args[1]);
              ObjectInputStream istream = new ObjectInputStream(fis);

              TextArea ta = (TextArea)istream.readObject();

              System.out.println(
                "expected scrollbar visibility = " + area.getScrollbarVisibility()
                + ", received scrollbar visibility = " + ta.getScrollbarVisibility()
              );

            } catch(Exception e) {
              System.out.println("Unexpected exception : " + e);
            }
          }

          System.exit(0);
        }
      }
      -------------The test output---------
      JKD1.1.6:
      > java -version
      java version "1.1.6"
      > java TextAreaTest write file
      file is successfuly created

      JDK1.2:
      > java -version
      java version "1.2fcs"
      Classic VM (build JDK-1.2fcs-L, green threads, sunwjit)
      > java TextAreaTest read file
      expected scrollbar visibility = 0, received scrollbar visibility = 5

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ehawkessunw Eric Hawkes (Inactive)
                Reporter:
                ovlasov Oleksandr Vlasov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: