United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4759974 : Field WindowEvent.opposite should be transient

Details
Type:
Bug
Submit Date:
2002-10-08
Status:
Resolved
Updated Date:
2002-11-01
Project Name:
JDK
Resolved Date:
2002-11-01
Component:
client-libs
OS:
generic
Sub-Component:
java.awt
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
1.4.2 (mantis)

Related Reports
Relates:

Sub Tasks

Description
Since the source field on event object is transient, it is very unlikely that
someone can deduce anything useful from opposite field. Deserialized window
could have never actually be activated or receive focus. So null seems to be
the only possible value for WindowEvent.opposite field after deserialization.

There was a similar issue with FocusEvent.opposite reported by a customer from
HP (see bug id 4715486). This was resolved by making the field explicitly
serialize and deserialize to null. Michael Warres pointed out that since the
observable behaviour in this case is the same as if the field was transient, we
can as well make it transient. So I believe the issue of 4715486 needs to be
revisited and both WindowEvent.opposite and FocusEvent.opposite must be
transient. 

                                    

Comments
EVALUATION

If we decided to change FocusEvent, WindowEvent needs to be changed, too.
###@###.### 2002-10-08
                                     
2002-10-08
SUGGESTED FIX

------- FocusEvent.java -------
*** /tmp/sccs.8layxY    Thu Oct 10 15:05:18 2002
--- FocusEvent.java     Thu Oct 10 15:02:19 2002
***************
*** 13,23 ****
  import sun.awt.AppContext;
  import sun.awt.SunToolkit;

- import java.io.Serializable;
- import java.io.ObjectOutputStream;
- import java.io.ObjectInputStream;
- import java.io.IOException;
-
  /**
   * A low-level event which indicates that a Component has gained or lost the
   * input focus. This low-level event is generated by a Component (such as a
--- 13,18 ----
***************
*** 90,100 ****
       * with a native application, a Java application in a different VM, or with
       * no other Component, then the opposite Component is null.
       *
-      * @serial
       * @see #getOppositeComponent
       * @since 1.4
       */
!     Component opposite;

      /*
       * JDK 1.1 serialVersionUID
--- 85,94 ----
       * with a native application, a Java application in a different VM, or with
       * no other Component, then the opposite Component is null.
       *
       * @see #getOppositeComponent
       * @since 1.4
       */
!     transient Component opposite;

      /*
       * JDK 1.1 serialVersionUID
***************
*** 212,239 ****
            ",opposite=" + getOppositeComponent();
      }

-     /**
-      * Reads serializable fields from stream. We need to do it explicitly
-      * to make sure opposite component deserializes to null even if it
-      * is present in the stream.
-      */
-     private void readObject(ObjectInputStream s)
-              throws ClassNotFoundException, IOException {
-         ObjectInputStream.GetField f = s.readFields();
-         temporary = f.get("temporary", false);
-         opposite = null;
-     }
-
-     /**
-      * Writes serializable fields to stream. We need to do it explicitly
-      * to avoid serializing opposite component.
-      */
-     private void writeObject(ObjectOutputStream s)
-                                   throws IOException {
-         ObjectOutputStream.PutField f = s.putFields();
-         f.put("temporary", temporary);
-         f.put("opposite", (Component)null);
-         s.writeFields();
-     }
-
  }
--- 206,209 ----

------- WindowEvent.java -------
*** /tmp/sccs.RLaWxY    Thu Oct 10 15:05:36 2002
--- WindowEvent.java    Thu Oct 10 15:03:54 2002
***************
*** 137,147 ****
       * native application, a Java application in a different VM, or with no
       * other Window, null is returned.
       *
-      * @serial
       * @see #getOppositeWindow
       * @since 1.4
       */
!     Window opposite;

      /**
       * TBS
--- 137,146 ----
       * native application, a Java application in a different VM, or with no
       * other Window, null is returned.
       *
       * @see #getOppositeWindow
       * @since 1.4
       */
!     transient Window opposite;

      /**
       * TBS
                                     
2004-06-11
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mantis

FIXED IN:
mantis

INTEGRATED IN:
mantis
mantis-b06


                                     
2004-06-14



Hardware and Software, Engineered to Work Together