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

DropTarget notify methods inconsistency

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 5.0
    • client-libs
    • sparc
    • solaris_2.6



      Name: sdR10048 Date: 08/15/2003


      Filed By : SPB JCK team (###@###.###)
      JDK : java full version "1.5.0-beta-b13"

      Specification excerpt:
      ======================
      --------- J2SE API spec v.1.5 ---------
      ...
      public void dragEnter(DropTargetDragEvent dtde)
        Calls dragEnter on the registered DropTargetListener and passes it the specified
        DropTargetDragEvent. Has no effect if this DropTarget is not active.

      Parameters:
        dtde - the DropTargetDragEvent
      Throws:
        NullPointerException - if this DropTarget is active and dtde is null

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

      Problem description
      ===================
      Currently spec does not describe will DropTarget notify the registered listener
      in case if this DropTarget is active and 'dtde' is null.

      JDK 1.5.0 b13 does notify the listener with a null event.

      The same issue with some other methods as well:

      dragExit
      dragOver
      drop
      dropActionChanged

          
      Minimized test:
      ===============
      ------- T.java -------
      import java.awt.dnd.*;

      public class T implements DropTargetListener {

          private String method = null;

          public String getMethod() {
              return method;
          }

          public void dragEnter(DropTargetDragEvent dsde) {method = "dragEnter";}

          public void dragOver(DropTargetDragEvent dsde) {method = "dragOver";}

          public void dropActionChanged(DropTargetDragEvent dsde) {method = "dropActionChanged";}

          public void dragExit(DropTargetEvent dsde) {method = "dragExit";}

          public void drop(DropTargetDropEvent dsde) {method = "drop";}

          public T() {
          }

          public static void main(String[] args) {
              DropTarget dt = new DropTarget();
              T t = new T();
              try {
                  dt.addDropTargetListener(t);
              } catch (Exception e) {
                  e.printStackTrace();
              }
              dt.setActive(true);
              System.out.println("t.getMethod(): "+t.getMethod());
              try {
                  dt.dragEnter(null);
              } catch (NullPointerException e) {
                  System.out.println("NPE: "+e);
              }
              System.out.println("t.getMethod(): "+t.getMethod());
          }
      }

      ------- end-of-T.java -------

      Minimized test output:
      ======================
      t.getMethod(): null
      NPE: java.lang.NullPointerException
      t.getMethod(): dragEnter

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

            agerasimsunw Alexander Gerasimov (Inactive)
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: