United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4123385 : spec for ctor java.awt.dnd.DragSourceDragEvent unclear

Details
Type:
Bug
Submit Date:
1998-03-27
Status:
Closed
Updated Date:
2004-09-15
Project Name:
JDK
Resolved Date:
2004-09-15
Component:
client-libs
OS:
solaris_2.5,solaris_7,generic
Sub-Component:
java.awt
CPU:
sparc,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.2.0,1.4.0,5.0
Fixed Versions:
5.0 (tiger)

Related Reports
Duplicate:
Relates:
Relates:
Relates:

Sub Tasks

Description
Name: sdC67446			Date: 03/27/98


The specification for ctor
java.awt.dnd.DragSourceDragEvent(DragSourceContext, int dropActions,
int actions, int modifiers) does not specify behavior for argument 
'dropActions' and 'actions' when they are invalid. Currently ctor ingnores
invalid values. More acceptable behavior for all invalid actions here
is to throw IllegalArgumentException unless otherwise specified.
The same obscurity exists in ctors
DragSourceDropEvent(DragSourceContext, int action),
TargetDragEvent(DropTargetContext, Point, int dropAction, int srcAction),
DropTargetDropEvent(DropTargetContext, Point, int dropAction, int srcActions)
as well.

Here is what doc says:
--------------------------------------------------
ublic DragSourceDragEvent(DragSourceContext dsc,
                           int dropAction,
                           int actions,
                           int modifiers)

      construct a DragSourceEvent
--------------------------------------------------
======================================================================

                                    

Comments
SUGGESTED FIX

*** /tmp/geta29123      Fri Feb 22 15:39:26 2002
--- DragSourceDragEvent.java    Fri Feb 22 15:41:37 2002
***************
*** 76,81 ****
--- 76,89 ----
       *        should be used, but both models should not be mixed
       *        in one event. Use of the extended modifiers is
       *        preferred.
+      * @throws <code>IllegalArgumentException</code> if dropAction is not one of
+      *         <code>DnDConstants</code>.
+      * @throws <code>IllegalArgumentException</code> if actions is not one of
+      *         <code>DnDConstants</code>.
+      * @throws <code>IllegalArgumentException</code> if modifiers is neither a
+      *         bitwise mask of old InputEvent.*_MASK constants nor a bitwise
+      *         mask of extended InputEvent.*_DOWN_MASK constants.
+      * @throws <code>NullPointerException</code> if dsc is <code>null</code>.
       * @see java.awt.event.InputEvent
       * @see DragSourceEvent#getLocation
       */
***************
*** 84,89 ****
--- 92,116 ----
                                 int actions, int modifiers) { 
        super(dsc);
        
+       if (dropAction != DnDConstants.ACTION_NONE &&
+           dropAction != DnDConstants.ACTION_COPY &&
+           dropAction != DnDConstants.ACTION_MOVE &&
+           dropAction != DnDConstants.ACTION_LINK) {
+             throw new IllegalArgumentException("Illegal dropAction");
+         }
+ 
+       if (actions != DnDConstants.ACTION_NONE &&
+           actions != DnDConstants.ACTION_COPY &&
+           actions != DnDConstants.ACTION_MOVE &&
+           actions != DnDConstants.ACTION_LINK) {
+             throw new IllegalArgumentException("Illegal actions");
+         }
+ 
+       if ((modifiers & JDK_1_3_MODIFIRS) != 0 &&
+             (modifiers & JDK_1_4_MODIFIRS) != 0) {
+             throw new IllegalArgumentException("Illegal modifiers");
+         }
+ 
        targetActions    = actions;
        gestureModifiers = modifiers;
        this.dropAction  = dropAction;
***************
*** 106,111 ****
--- 133,146 ----
       *        preferred.
       * @param x   the horizontal coordinate for the cursor location
       * @param y   the vertical coordinate for the cursor location
+      * @throws <code>IllegalArgumentException</code> if dropAction is not one of
+      *         <code>DnDConstants</code>.
+      * @throws <code>IllegalArgumentException</code> if actions is not one of
+      *         <code>DnDConstants</code>.
+      * @throws <code>IllegalArgumentException</code> if modifiers is neither a
+      *         bitwise mask of old InputEvent.*_MASK constants nor a bitwise
+      *         mask of extended InputEvent.*_DOWN_MASK constants.
+      * @throws <code>NullPointerException</code> if dsc is <code>null</code>.
       * @see java.awt.event.InputEvent
       * @since 1.4
       */
***************
*** 113,118 ****
--- 148,172 ----
                                 int actions, int modifiers, int x, int y) {
          super(dsc, x, y);
  
+       if (dropAction != DnDConstants.ACTION_NONE &&
+           dropAction != DnDConstants.ACTION_COPY &&
+           dropAction != DnDConstants.ACTION_MOVE &&
+           dropAction != DnDConstants.ACTION_LINK) {
+             throw new IllegalArgumentException("Illegal dropAction");
+         }
+ 
+       if (actions != DnDConstants.ACTION_NONE &&
+           actions != DnDConstants.ACTION_COPY &&
+           actions != DnDConstants.ACTION_MOVE &&
+           actions != DnDConstants.ACTION_LINK) {
+             throw new IllegalArgumentException("Illegal actions");
+         }
+ 
+       if ((modifiers & JDK_1_3_MODIFIRS) != 0 &&
+             (modifiers & JDK_1_4_MODIFIRS) != 0) {
+             throw new IllegalArgumentException("Illegal modifiers");
+         }
+ 
          targetActions    = actions;
          gestureModifiers = modifiers;
          this.dropAction  = dropAction;
***************
*** 134,139 ****
--- 188,195 ----
  
  
      static final int JDK_1_3_MODIFIERS = InputEvent.SHIFT_DOWN_MASK - 1;
+     static final int JDK_1_4_MODIFIERS = 
+         (InputEvent.ALT_GRAPH_DOWN_MASK << 1 - 1) & ~JDK_1_3_MODIFIERS;
  
      /**
       * This method returns an <code>int</code> representing
***************
*** 159,165 ****
       */
  
      public int getGestureModifiersEx() {
!       return gestureModifiers & ~JDK_1_3_MODIFIERS;
      }
  
      /**
--- 215,221 ----
       */
  
      public int getGestureModifiersEx() {
!       return gestureModifiers & JDK_1_4_MODIFIERS;
      }
  
      /**


###@###.### 2002-03-04
                                     
2002-03-04
EVALUATION

Name: sdR10048			Date: 11/23/2001


this (jck14a) test has the same problem:
api/java_awt/dnd/DragSourceDropEvent/index.html#Ctor2[DragSourceDropEvent0011]


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

Commit to fix in Hopper (JCK-exclude list).  
###@###.### 2001-12-02 

Evaluation by the responsible engineer:  

> the bug 4123385 is committed to hopper. To fix it we need to
> 1) modify the behavior, so that IllegalArgumentException is thrown
> when invalid arguments are passed and 2) update the javadoc to specify
> this exception.

Since this is a request for an API change, I don't believe it can be fixed 
in Hopper.  We will submit a CCC request for the change the submitter has 
requested in Tiger.  

###@###.### 2002-03-04


Name: agR10216			Date: 07/25/2003


The following CCC request was approved:

 4123385: spec for ctor java.awt.dnd.DragSourceDragEvent unclear
 Release: Tiger
 Type: bug-fix
 Manager: jeff.dinkins
 Engineer: ###@###.###
 
 Problem
 
 The following constructors (in java.awt.dnd package) throw
 IllegalArgumentException if the argument dsc is null, but
 it is not specified:
 DragSourceEvent(DragSourceContext dsc)
 DragSourceEvent(DragSourceContext dsc, int x, int y)
 DragSourceDragEvent(DragSourceContext dsc, int dropAction,
                     int actions, int modifiers)
 DragSourceDragEvent(DragSourceContext dsc, int dropAction,
                     int actions, int modifiers, int x, int y)
 DragSourceDropEvent(DragSourceContext dsc)
 DragSourceDropEvent(DragSourceContext dsc, int action,
                     boolean success)
 DragSourceDropEvent(DragSourceContext dsc, int action,
                     boolean success, int x, int y)
 
 The constructors
 DragSourceDragEvent(DragSourceContext dsc, int dropAction,
                     int actions, int modifiers) and
 DragSourceDragEvent(DragSourceContext dsc, int dropAction,
                     int actions, int modifiers, int x, int y)
 do not throw any exceptions if their arguments dropAction,
 actions or modifiers are invalid, but it is not specified.
 
 The ctors
 DragSourceDropEvent(DragSourceContext dsc, int action,
                                       boolean success) and
 DragSourceDropEvent(DragSourceContext dsc, int action,
                         boolean success, int x, int y)
 do not throw any exeptions if their argument action is
 invalid, but it is not specified.
 
 There are 3 JCK bugs on these issues:
 4123385 [spec for ctor java.awt.dnd.DragSourceDragEvent unclear]
 4219341 [incomplete doc for java.awt.dnd.DragSourceDragEvent]
 4219342 [incomplete doc for java.awt.dnd.DragSourceDropEvent]
 
 Since behavior changes are objectionable, the current behavior
 should be specified for JCK testing.
 
 
 Requestors
 Java Drag and Drop team
 JCK team
 
 
 Solution
 
 Specify the current behavior with respect to invalid arguments
 passed to the constructors in question.
 
 
 Interface summary
 
 exported  external  method  java.awt.dnd.DragSourceEvent(DragSourceContext dsc, int x, int y)
                                          DragSourceEvent(DragSourceContext dsc, int x, int y)
                                          DragSourceDragEvent(DragSourceContext dsc, int dropAction,
                                                              int actions, int modifiers)
                                          DragSourceDragEvent(DragSourceContext dsc, int dropAction,
                                                              int actions, int modifiers, int x, int y)
                                          DragSourceDropEvent(DragSourceContext dsc)
                                          DragSourceDropEvent(DragSourceContext dsc, int action,
                                                              boolean success)
                                          DragSourceDropEvent(DragSourceContext dsc, int action,
                                                              boolean success, int x, int y)
 
                         
 Specification
 
 java.awt.dnd:
 
     /**
      * Construct a <code>DragSourceEvent</code>
      * given a specified <code>DragSourceContext</code>.
      * The coordinates for this <code>DragSourceEvent</code>
      * are not specified, so <code>getLocation</code> will return
      * <code>null</code> for this event.
      *
      * @param dsc the <code>DragSourceContext</code>
 +    *
 +    * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
 +    *
      * @see #getLocation
      */
 
     public DragSourceEvent(DragSourceContext dsc)
 
 
     
     /**
      * Construct a <code>DragSourceEvent</code> given a specified
      * <code>DragSourceContext</code>, and coordinates of the cursor
      * location.
      *
      * @param dsc the <code>DragSourceContext</code>
      * @param x   the horizontal coordinate for the cursor location
      * @param y   the vertical coordinate for the cursor location
 +    *
 +    * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
 +    *
      * @since 1.4
      */
     public DragSourceEvent(DragSourceContext dsc, int x, int y)
 
 
 
     /**
      * Constructs a <code>DragSourceDragEvent</code>.
      * This class is typically
      * instantiated by the <code>DragSourceContextPeer</code>
      * rather than directly
      * by client code.
      * The coordinates for this <code>DragSourceDragEvent</code>
      * are not specified, so <code>getLocation</code> will return
      * <code>null</code> for this event.
 +    * <p>
 +    * The arguments <code>dropAction</code> and <code>action</code> should
 +    * be one of <code>DnDConstants</code> that represents a single action.
 +    * The argument <code>modifiers</code> should be either a bitwise mask
 +    * of old <code>java.awt.event.InputEvent.*_MASK</code> constants or a
 +    * bitwise mask of extended <code>java.awt.event.InputEvent.*_DOWN_MASK</code>
 +    * constants.
 +    * This constructor does not throw any exception for invalid <code>dropAction</code>,
 +    * <code>action</code> and <code>modifiers</code>.
      *
      * @param dsc the <code>DragSourceContext</code> that is to manage
      *            notifications for this event.
      * @param dropAction the user drop action.
      * @param action the target drop action.
      * @param 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 <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
 +    *
      * @see java.awt.event.InputEvent
      * @see DragSourceEvent#getLocation
      */
 
     public DragSourceDragEvent(DragSourceContext dsc, int dropAction,
                                int action, int modifiers)
     
 
 
     /**
      * Constructs a <code>DragSourceDragEvent</code> given the specified
      * <code>DragSourceContext</code>, user drop action, target drop action,
      * modifiers and coordinates.
 +    * <p>
 +    * The arguments <code>dropAction</code> and <code>action</code> should
 +    * be one of <code>DnDConstants</code> that represents a single action.
 +    * The argument <code>modifiers</code> should be either a bitwise mask
 +    * of old <code>java.awt.event.InputEvent.*_MASK</code> constants or a
 +    * bitwise mask of extended <code>java.awt.event.InputEvent.*_DOWN_MASK</code>
 +    * constants.
 +    * This constructor does not throw any exception for invalid <code>dropAction</code>,
 +    * <code>action</code> and <code>modifiers</code>.
      *
      * @param dsc the <code>DragSourceContext</code> associated with this
      *        event.
      * @param dropAction the user drop action.
      * @param action the target drop action.
      * @param 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.
      * @param x   the horizontal coordinate for the cursor location
      * @param y   the vertical coordinate for the cursor location
 +    *
 +    * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
 +    *
      * @see java.awt.event.InputEvent
      * @since 1.4
      */
     public DragSourceDragEvent(DragSourceContext dsc, int dropAction,
                                int action, int modifiers, int x, int y)
 
 
                                
     /**
      * Construct a <code>DragSourceDropEvent</code>
      * for a drag that does not result in a drop.
      * The coordinates for this <code>DragSourceDropEvent</code>
      * are not specified, so <code>getLocation</code> will return
      * <code>null</code> for this event.
      *
      * @param dsc the <code>DragSourceContext</code>
 +    *
 +    * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
 +    *
      * @see DragSourceEvent#getLocation
      */
 
     public DragSourceDropEvent(DragSourceContext dsc)
 
 
     
     /**
      * Construct a <code>DragSourceDropEvent</code> for a drop,
      * given the
      * <code>DragSourceContext</code>, the drop action,
      * and a <code>boolean</code> indicating if the drop was successful.
      * The coordinates for this <code>DragSourceDropEvent</code>
      * are not specified, so <code>getLocation</code> will return
      * <code>null</code> for this event.
 +    * <p>
 +    * The argument <code>action</code> should be one of <code>DnDConstants</code>
 +    * that represents a single action.
 +    * This constructor does not throw any exception for invalid <code>action</code>.
      *
      * @param dsc the <code>DragSourceContext</code>
      * associated with this <code>DragSourceDropEvent</code>
      * @param action the drop action
      * @param success a boolean indicating if the drop was successful
 +    *
 +    * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
 +    *
      * @see DragSourceEvent#getLocation
      */
 
     public DragSourceDropEvent(DragSourceContext dsc, int action, boolean success)
 
 
     
     /**
      * Construct a <code>DragSourceDropEvent</code> for a drop, given the
      * <code>DragSourceContext</code>, the drop action, a <code>boolean</code>
      * indicating if the drop was successful, and coordinates.
 +    * <p>
 +    * The argument <code>action</code> should be one of <code>DnDConstants</code>
 +    * that represents a single action.
 +    * This constructor does not throw any exception for invalid <code>action</code>.
      *
      * @param dsc the <code>DragSourceContext</code>
      * associated with this <code>DragSourceDropEvent</code>
      * @param action the drop action
      * @param success a boolean indicating if the drop was successful
      * @param x   the horizontal coordinate for the cursor location
      * @param y   the vertical coordinate for the cursor location
 +    *
 +    * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
 +    *
      * @since 1.4
      */
     public DragSourceDropEvent(DragSourceContext dsc, int action,
                                boolean success, int x, int y)
                                
 
                                
 Compatibility risk: minimal


###@###.###  2003-07-25


======================================================================
                                     
2003-07-25
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b15

VERIFIED IN:
1.5


                                     
2004-09-17



Hardware and Software, Engineered to Work Together