JDK-4759974 : Field WindowEvent.opposite should be transient
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2002-10-08
  • Updated: 2002-11-01
  • Resolved: 2002-11-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2 mantisFixed
Related Reports
Relates :  
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
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis FIXED IN: mantis INTEGRATED IN: mantis mantis-b06
14-06-2004

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
11-06-2004

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