-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.2.0
-
sparc
-
solaris_2.5
Name: sdC67446 Date: 03/13/98
method java.awt.dnd.DragSourceConetxt(DragSource ds,
java.awt.dnd.peer.DragSourceContextPeer dscp, Component c,
int a, Cursor dragCursor, Image dragImage, Point offset,
Transferable t, DragSourceListener dsl) doesn't permit null for
parameters: ds, dscp, c and t, and does it for other parameters.
More convenient behavior here is to throw NullPointerException
for all null parameters or else it should be figured in spec.
Here is doc issues:
--------------------------------------------------
public DragSourceContext(DragSource ds,
java.awt.dnd.peer.DragSourceContextPeer dscp,
Component c,
int a,
Cursor dragCursor,
Image dragImage,
Point offset,
Transferable t,
DragSourceListener dsl)
construct a DragSourceContext (called from DragSource)
Parameters:
ds - The DragSource that originated this operation
dscp - The DragSourceContextPeer for this operation
a - The operation(s)
dragCursor - The initial Cursor
dragImage - The image to drag (or null)
offset - The offset of the image origin from the hotspot
at the instant of the triggering event
t - The Transferable
dsl - The DragSourceListener
Here is the test demostrating the bug:
-----------------Test.java------------------------
import java.awt.*;
import java.awt.image.*;
import java.awt.dnd.*;
import java.awt.dnd.peer.*;
import java.awt.datatransfer.*;
public class Test {
public static void main(String[] args) {
DragSource ds = new DragSource();
DragSourceContextPeer dscp = new DragSourceContextPeer() {
public void startDrag(DragSourceContext ds, AWTEvent trigger,
Cursor cursor, int actions) {}
public Component getComponent() { return null; }
public void cancelDrag() {}
public Cursor getCursor() { return null; }
public void setCursor(Cursor c) {}
public AWTEvent getTrigger() {return null;}
};
Component component = new Button();
int actions = DnDConstants.ACTION_COPY;
Cursor cursor = DragSource.DefaultCopyDrop;
Image image = new Image() {
public int getWidth(ImageObserver observer) {return 0;}
public int getHeight(ImageObserver observer){return 0;}
public ImageProducer getSource() {return null;}
public Graphics getGraphics() {return null;}
public void flush() {}
public Object getProperty(String name, ImageObserver observer) {
return null;
}
};
Point point = new Point(0,0);
Transferable transferable = new Transferable() {
public Object getTransferData(DataFlavor df) {
return null;
}
public DataFlavor[] getTransferDataFlavors() {
return null;
}
public boolean isDataFlavorSupported(DataFlavor df) {
return false;
}
};
DragSourceListener dsl = new DragSourceListener() {
public void dragEnter(DragSourceDragEvent dsde) {}
public void dragOver(DragSourceDragEvent dsde) {}
public void dropActionChanged(DragSourceDragEvent dsde) {}
public void dragExit(DragSourceEvent dsde) {}
public void dragDropEnd(DragSourceDropEvent dsde) {}
};
DragSourceContext dsc = null;
try {
dsc = new DragSourceContext(ds,
dscp,
component,
actions,
null, // cursor
image,
null, // point
transferable,
null // dsl
);
} catch (NullPointerException e) {
System.out.println(e);
}
System.out.println("No reaction,");
try {
// every null parameter below can cause NPE if alone.
dsc = new DragSourceContext(null, // ds
null, // dscp
null, // component
actions,
cursor,
image,
point,
null, // transferable
dsl
);
} catch (NullPointerException e) {
System.out.println("but here is "+e);
}
}
}
---------Output from the test---------------------
No reaction,
but here is java.lang.NullPointerException: DragSource
--------------------------------------------------
======================================================================