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

The doc for java.awt.dnd.DropTargetDropEvent is wrong

XMLWordPrintable

    • sparc
    • solaris_2.5

      Name: akC97680 Date: 12/03/99



      javadoc documentation for
      java.awt.dnd.DropTargetDropEvent.DropTargetDropEvent(java.awt.dnd.DropTargetContext
      dtc,java.awt.Point,int,int) does not correspond implementation. If dtc is null,
      implementation throws NullPointerException while javadoc says that
      IllegalArgumentException must be thrown.

      The javadoc spec states:
      -------------------------------------------------------
      DropTargetDropEvent

      public DropTargetDropEvent(DropTargetContext dtc,
                                 Point cursorLocn,
                                 int dropAction,
                                 int srcActions)

      --- skip ---

            Throws:
                  NullPointerException - if cursorLocn is null
                  IllegalArgumentException - if the dropAction or srcActions are illegal values,
                                             or if dtc is null.
                                             ^^^^^^^^^^^^^^^^^

      -------------------------------------------------------


      Here is a sample code demonstrating this bug:


      --------------------- Test.java -----------------------

      import java.awt.Point;
      import java.awt.dnd.*;

      public class Test {
          public static void main(String[] argv) {
              try {
                  DropTargetDropEvent dtde =
                      new DropTargetDropEvent(null,
                                              new Point(0,0),
                                              DnDConstants.ACTION_NONE,
                                              DnDConstants.ACTION_NONE);
              } catch (IllegalArgumentException iae) {
                  System.out.println("Passed: the documentations complies " +
                                     "implementation");
              } catch (NullPointerException npe) {
                  System.out.println("Failed: the documentation does not comply " +
                                     "implementation");
              }
          }
      }

      -------------------------------------------------------


      Test output (jdk1.3):
      -------------------------------------------------------
      %java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-P)
      Java HotSpot(TM) Client VM (build 1.3-P, interpreted mode)
      %java Test
      Failed: the documentation does not comply implementation

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

            denis Denis Fokin (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: