JDK-4924527 : java.awt.dnd.DragSourceDragEvent.getModifiers[Ex] and invalid modifiers
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 2003-09-18
  • Updated: 2017-05-16
  • Resolved: 2003-12-18
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 Availabitlity Release.

To download the current JDK release, click here.
Other
5.0 b32Fixed
Related Reports
Relates :  
Description

Name: sdR10048			Date: 09/18/2003


Filed By      : SPB JCK team (###@###.###)
JDK           : java full version "1.5.0-beta-b18"
JCK           : 1.5
Platform[s]   : Solaris
switch/Mode   : 
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] :
    api/java_awt/dnd/DragSourceDragEvent/index.html#Ctor[DragSourceDragEvent0005]
    api/java_awt/dnd/DragSourceDragEvent/index.html#Ctor2[DragSourceDragEvent0011]


Specification excerpt:
======================
--------- J2SE API spec v.1.5 ---------
...
public DragSourceDragEvent(DragSourceContext?dsc,
                           int?dropAction,
                           int?action,
                           int?modifiers)

Constructs a DragSourceDragEvent. This class is typically instantiated by the DragSourceContextPeer rather than directly by client code. The coordinates for this DragSourceDragEvent are not specified, so getLocation will return null for this event.

The arguments dropAction and action should be one of DnDConstants that represents a single action. The argument modifiers should be either a bitwise mask of old java.awt.event.InputEvent.*_MASK constants or a bitwise mask of extended java.awt.event.InputEvent.*_DOWN_MASK constants. This constructor does not throw any exception for invalid dropAction, action and modifiers.

Parameters:
dsc - the DragSourceContext that is to manage notifications for this event.
dropAction - the user drop action.
action - the target drop action.
modifiers - the modifier keys down during event (shift, ctrl, alt, meta) Either extended _DOWN_MASK or old _MASK modifiers should be used, but both models should not be mixed in one event. Use of the extended modifiers is preferred.
Throws:
IllegalArgumentException - if dsc is null.

---

public int getGestureModifiers()

This method returns an int representing the current state of the input device modifiers associated with the user's gesture. Typically these would be mouse buttons or keyboard modifiers.

Returns:
the current state of the input device modifiers

---

public int getGestureModifiersEx()

This method returns an int representing the current state of the input device extended modifiers associated with the user's gesture. See InputEvent.getModifiersEx()

Returns:
the current state of the input device extended modifiers

...
---------- end-of-excerpt ---------------

Problem description
===================
The spec says that constructors accept (do not throw any exception) invalid modifiers. Modifiers can be: the "ordinary" and the extended ones.

So some words about where (getModifiers or getModifiersEx) to get the 
passed in invalid modifiers should be said here.


JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests

Test output:
=============
BadModifier's found: 16384
drag source context | was      : java.awt.dnd.DragSourceContext@1df5a8f
                    | expected : java.awt.dnd.DragSourceContext@1df5a8f
user action         | was      : 0
                    | expected : 0
target actions      | was      : 0
                    | expected : 0
gesture modifiers   | was      : 0
gesture modifiersEx | was      : 16384
gesture modifiers   | expected : 16384
----------log:(7/407)----------
Warning: Cannot convert string "-monotype-arial-regular-r-normal--*-140-*-*-p-*-iso8859-1" to type FontStruct
DragSourceDragEvent0001: Passed. OK
DragSourceDragEvent0002: Passed. OK
DragSourceDragEvent0003: Passed. OK
DragSourceDragEvent0004: Passed. OK
DragSourceDragEvent0005: Failed. Bad class instance.

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

Name: sdR10048			Date: 09/22/2003

The real failing tests are:
    api/java_awt/dnd/DragSourceDragEvent/index.html#Ctor[DragSourceDragEvent0005] 
    api/java_awt/dnd/DragSourceDragEvent/index.html#Ctor2[DragSourceDragEvent0013] 

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

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta FIXED IN: tiger-beta INTEGRATED IN: tiger-b32 tiger-beta VERIFIED IN: tiger-b40
2004-08-24

EVALUATION Additional API documentation about getModifiers or getModifiersEx in java.awt.dnd.DragSourceDragEvent ###@###.### 2003-09-21 I ran my suggested fix by Alexander and he spoke to the submitter about it. He feels that to fix this properly requires both a software and a doc change. So, I am reclassifying this bug and assigning to him. ###@###.### 2003-10-29 Name: agR10216 Date: 11/26/2003 The folllowing CCC request was approved on 11/25/2003. There was an additional discussion on compatibility risks, refer to the section Comments. 4924527: java.awt.dnd.DragSourceDragEvent.getModifiers[Ex] and invalid modifiers Release: tiger-beta Type: bug-fix Manager: jeff.dinkins Engineer: ###@###.### Problem The constructors java.awt.dnd.DragSourceDragEvent(DragSourceContext dsc, int dropAction, int actions, int modifiers) and java.awt.dnd.DragSourceDragEvent(DragSourceContext dsc, int dropAction, int actions, int modifiers, int x, int y) do not throw any exceptions if their argument modifiers is invalid. This behavior, as well as the notion of 'invalid mofifiers' is specified. The methods DragSourceDragEvent.getGestureModifiers() and DragSourceDragEvent.getGestureModifiersEx() return the modifiers passed to a constructor of this class and converted to old or extended ones correspondingly. For proper revision of JCK tests it's required to specify the behavior of the methods getGestureModifiers() and getGestureModifiersEx() with respect to invalid modifiers passed to a constructor of the class. This is a red JCK bug. There is a bug in determining which modifiers are invalid and in converting them, so in addition to clarifying the spec we need to update the implementation. Requestors Java Drag and Drop team JCK team Solution Specify that getGestureModifiers() and getGestureModifiersEx() return invalid modifiers unchanged and update the implementation of the class DragSourceDragEvent accordingly. Updating the implementation has minimal impact on compatibility since it deals only with invalid modifiers. The fix includes adding of a private field to the class; according to the serialization spec this is a compatible change. Interface summary exported external method java.awt.dnd.DragSourceDragEvent.getGestureModifiers() exported external method java.awt.dnd.DragSourceDragEvent.getGestureModifiersEx() // If a private field that appears in the serialized form of the class must be taken into account, then: exported external field java.awt.dnd.DragSourceDragEvent.invalidModifiers Specification java.awt.dnd.DragSourceDragEvent: The following private field appear in the serialized form of the class: + /** + * Indicates whether the <code>gestureModifiers</code> are invalid. + * + * @serial + */ + private boolean invalidModifiers; /** * This method returns an <code>int</code> representing * the current state of the input device modifiers * associated with the user's gesture. Typically these * would be mouse buttons or keyboard modifiers. * <P> + * If the <code>modifiers</code> passed to the constructor + * are invalid, this method returns them unchanged. + * * @return the current state of the input device modifiers */ public int getGestureModifiers() /** * This method returns an <code>int</code> representing * the current state of the input device extended modifiers * associated with the user's gesture. * See {@link InputEvent#getModifiersEx} * <P> + * If the <code>modifiers</code> passed to the constructor + * are invalid, this method returns them unchanged. + * * @return the current state of the input device extended modifiers * @since 1.4 */ public int getGestureModifiersEx() Compatibility risk: minimal ###@###.### 2003-11-26 ======================================================================
2003-11-26