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

java.awt.Frame serialization is specifyed incorrectly

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.6



      Name: ooR10001 Date: 08/24/2000


      java.awt.Frame serialization is incorrect. readObject() and writeObject() methods
      of the java.awt.Frame class have undocumented behavior.

      javadoc says:
      ---------------------------------
      readObject

      private void readObject(ObjectInputStream s)
                       throws ClassNotFoundException,
                              IOException

            Reads the ObjectInputStream and if it isn't null, adds a listener to receive
            item events fired by the Frame. Unrecognized keys or values will be ignored.
            See Also:
                  removeActionListener(), addActionListener()

      writeObject

      private void writeObject(ObjectOutputStream s)
                        throws IOException

            Writes default serializable fields to stream. Writes a list of serializable
            ItemListeners as optional data. The non-serializable ItemListeners are
            detected and no attempt is made to serialize them.
            Serial Data:
                  null terminated sequence of 0 or more pairs; the pair consists of a
                  String and Object; the String indicates the type of object and is one
                  of the following: itemListenerK indicating and ItemListener object
            See Also:
                  java.awt.Component.itemListenerK
      --------------------------------------------------------

      Implementation in jdk1.4:
      --------------------------------------------------------
          private void writeObject(ObjectOutputStream s)
            throws IOException
          {
            s.defaultWriteObject();
            if (icon instanceof Serializable) {
                s.writeObject(icon);
            }
            else
            {
                s.writeObject(null);
            }
          }

          private void readObject(ObjectInputStream s)
            throws ClassNotFoundException, IOException
          {
            s.defaultReadObject();
            
            try {
        icon = (Image) s.readObject();
            } catch (java.io.OptionalDataException e) {
            // pre-1.4 instances will not have this optional data.
            // e.eof will be true to indicate that there is no more
            // data available for this object.

           // If e.eof is not true, throw the exception as it
           // might have been caused by unrelated reasons.
               if (!e.eof) {
                   throw (e);
                }
            }

            if (menuBar != null)
      menuBar.parent = this;

            // Ensure 1.1 serialized Frames can read & hook-up
            // owned windows properly
            //
            if (ownedWindows != null) {
                for (int i = 0; i < ownedWindows.size(); i++) {
      connectOwnedWindow((Window) ownedWindows.elementAt(i));
      }
                ownedWindows = null;
            }

            weakThis = new WeakReference(this);
            addToFrameList();
          }
      -----------------------------------------------------

      This code uses 'icon' and it is not described in spec. Also, a stream prepared by
      implementation does not match the spec and must be documented completely.

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

            sharonz Sharon Zakhour (Inactive)
            oovsunw Oov Oov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: