United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4407057 DnDAcceptanceTest throws NullPointerException
JDK-4407057 : DnDAcceptanceTest throws NullPointerException

Details
Type:
Bug
Submit Date:
2001-01-23
Status:
Closed
Updated Date:
2002-01-21
Project Name:
JDK
Resolved Date:
2001-03-20
Component:
client-libs
OS:
generic
Sub-Component:
java.awt
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
1.4.0 (beta)

Related Reports
Relates:

Sub Tasks

Description
Although the dragging part of the test works, clicking on one of the "Drag ME!" buttons once it has been "dragged" onto the red field throws the following exception on Linux, Win32 and Solaris:

mouse pressed
starting Drag
java.lang.NullPointerException
        at sun.awt.datatransfer.DataTransferer.getFormatsForFlavors(DataTransferer.java:485)
        at sun.awt.datatransfer.DataTransferer.getFormatsForTransferable(DataTransferer.java:453)
        at sun.awt.dnd.SunDragSourceContextPeer.startDrag(SunDragSourceContextPeer.java:93)
        at java.awt.dnd.DragSource.startDrag(DragSource.java:297)
        at java.awt.dnd.DragSource.startDrag(DragSource.java:394)
        at java.awt.dnd.DragGestureEvent.startDrag(DragGestureEvent.java:196)
        at DnDSource.dragGestureRecognized(DnDSource.java:43)
        at java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(DragGestureRecognizer.java:342)
        at MyMouseDragGestureRecognizer.mousePressed(MyMouseDragGestureRecognizer.java:32)
        at java.awt.Component.processMouseEvent(Component.java:4859)
        at java.awt.Component.processEvent(Component.java:4688)
        at java.awt.Button.processEvent(Button.java:330)
        at java.awt.Component.dispatchEventImpl(Component.java:3460)
        at java.awt.Component.dispatchEvent(Component.java:3327)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:437)
        at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:140)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:126)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:121)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

It is also curious that on win32, clicking on the original "Drag Me!" button will initiate a drag, even though the user is no longer dragging.  Another click of the mouse will perform the "drop".


=====
During the 26Feb2001 AWT/DnD integration, Brent reported the following:

Clicking several buttons at once or in rapid succession on the "Drag Me" bar will seg fault pretty easily on Solaris.  On win32 this merely hangs.  Also in the promotion, so I'm still going to putback the integration.  Looks like it may be in the motif library, so perhaps there's not much that can be done.

-Brent


( 99 )bchristi@blackthorne: /home/bchristi/jano/Merlin-integrate/test/java/awt/d
nd/DnDAcceptanceTest % jdkx -r 1.4 sun.applet.AppletViewer DnDAcceptanceTest.htm
l 
/usr/local/java/jdk1.4/solsparc/bin/java sun.applet.AppletViewer DnDAcceptanceTe
st.html
mouse pressed
starting Drag
[Source] dragExit
[Source] dragDropEnd
mouse pressed
starting Drag
[Source] dragExit
[Source] dragExit
[Source] dragDropEnd
mouse pressed
starting Drag
[Source] dragExit
[Source] dragDropEnd
mouse pressed
starting Drag
[Source] dragExit
[Source] dragDropEnd
mouse pressed
starting Drag
[Source] dragExit
[Source] dragDropEnd
mouse pressed
starting Drag

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : 11 occurred at PC=0xffffffff2fbfd164
Function name=_XmAllocReceiverInfo
Library=/usr/dt/lib/sparcv9/libXm.so.4

Current Java thread:
        at sun.awt.motif.MToolkit.run(Native Method)
        at java.lang.Thread.run(Thread.java:579)

Dynamic libraries:
0x100000000     /usr/local/java/jdk1.4/solsparc/bin/../bin/sparcv9/native_thread
s/java
0xffffffff7f200000      /usr/lib/sparcv9/libthread.so.1
0xffffffff7f400000      /usr/lib/sparcv9/libdl.so.1
0xffffffff7ef00000      /usr/lib/sparcv9/libc.so.1
0xffffffff7ee00000      /usr/platform/SUNW,Ultra-5_10/lib/sparcv9/libc_psr.so.1
0xffffffff7d000000      /usr/local/java/jdk1.4/solsparc/jre/lib/sparcv9/server/l
ibjvm.so
0xffffffff7ce00000      /usr/lib/sparcv9/libCrun.so.1
0xffffffff7cc00000      /usr/lib/sparcv9/libsocket.so.1
0xffffffff7ca00000      /usr/lib/sparcv9/libnsl.so.1
0xffffffff7c800000      /usr/lib/sparcv9/libm.so.1
0xffffffff7d900000      /usr/lib/sparcv9/libw.so.1
0xffffffff7c500000      /usr/lib/sparcv9/libmp.so.2
0xffffffff7c300000      /usr/local/java/jdk1.4/solsparc/jre/lib/sparcv9/native_t
hreads/libhpi.so
0xffffffff7c000000      /usr/local/java/jdk1.4/solsparc/jre/lib/sparcv9/libverif
y.so
0xffffffff7bd00000      /usr/local/java/jdk1.4/solsparc/jre/lib/sparcv9/libjava.
so
0xffffffff7bb00000      /usr/local/java/jdk1.4/solsparc/jre/lib/sparcv9/libzip.s
o
0xffffffff30500000      /usr/local/java/jdk1.4/solsparc/jre/lib/sparcv9/libawt.s
o
0xffffffff30200000      /usr/local/java/jdk1.4/solsparc/jre/lib/sparcv9/motif21/
libmawt.so
0xffffffff30000000      /usr/local/java/jdk1.4/solsparc/bin/../jre/lib/sparcv9/l
ibmlib_image.so
0xffffffff2fb00000      /usr/dt/lib/sparcv9/libXm.so.4
0xffffffff2f900000      /usr/openwin/lib/sparcv9/libXt.so.4
0xffffffff2f700000      /usr/openwin/lib/sparcv9/libXext.so.0
0xffffffff2f500000      /usr/openwin/lib/sparcv9/libXtst.so.1
0xffffffff2f300000      /usr/openwin/lib/sparcv9/libX11.so.4
0xffffffff2f000000      /usr/openwin/lib/sparcv9/libSM.so.6
0xffffffff2ee00000      /usr/openwin/lib/sparcv9/libICE.so.6
0xffffffff2e000000      /usr/local/java/jdk1.4/solsparc/jre/lib/sparcv9/libfontm
anager.so
0xffffffff2da00000      /usr/lib/sparcv9/liblayout.so
0xffffffff2d800000      /usr/local/java/jdk1.4/solsparc/jre/lib/sparcv9/libnio.s
o
0xffffffff2d500000      /usr/lib/sparcv9/librt.so.1
0xffffffff2d300000      /usr/local/java/jdk1.4/solsparc/bin/../jre/lib/sparcv9/l
ibnet.so
0xffffffff2d100000      /usr/lib/sparcv9/libaio.so.1
0xffffffff2ce00000      /usr/lib/sparcv9/nss_files.so.1
0xffffffff2cb00000      /usr/local/java/jdk1.4/solsparc/bin/../jre/lib/sparcv9/l
ibsunwjdga.so
0xffffffff2c800000      /usr/openwin/lib/sparcv9/libdga.so.1

Local Time = Mon Feb 26 21:20:21 2001
Elapsed Time = 46
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.4beta-B53 mixed mode)
#
# An error report file has been saved as hs_err_pid21422.log.
# Please refer to the file for further information.
#
/java/jdk/bin/jdkx[12]: 21422 Abort(coredump)
( 100 )bchristi@blackthorne: /home/bchristi/jano/Merlin-integrate/test/java/awt/dnd/DnDAcceptanceTest %

                                    

Comments
EVALUATION

I am currently unable to reproduce the bug as described. Instead, the Button is
not being copied to the DropTarget at all. The serialization subsystem is
raising a ClassNotFoundException for MyMouseDragGestureRecognizer, even though
that class is in the same package (the same directory, in fact) as DnDSource.
There appears to be a serialization bug here. Marking incomplete until I can
figure out what is going on.
david.mendenhall@east 2001-01-26


Name: dsR10078			Date: 03/14/2001



The crash happens because native DnD subsystem doesn't work reliably
with our event dispatch mechanism. The drag is typically terminated
on button release event. If a native drag is initiated on a button
press and we do a rapid mouse clicks the corresponding button release
event is extracted from the native event queue and posted to java
before the drag starts. Drag-and-drop starts internal event pump, so
the button release event becomes unreachable. This way the drag won't
terminate until the next mouse click. On Solaris this causes more
severe effects because some Motif widgets (XmPushButton among them)
have Motif default drag support that conflicts with drag operations
initiated from java. 
Sometimes the drag remains alive even after the next mouse click.
In this case it is terminated with DropFinishTimeout.

In case of a drag operation initiated by Motif default drag support
DropFinishTimeout crashes when operates on a destroyed XmDragIcon object. 

There are two different crash scenarios:
1.As a result of a rapid mouse clicks we get an unterminated drag
  initiated by Motif drag support which crashes in DropFinishTimeout.
2.Initiate a Java drag operation and drop onto a red field.
  During the drop transfer the button is removed, so its underlying
  native widget is destroyed calling XmDragCancel for the unterminated
  drag operation initiated by Motif drag support. XmDragCancel crashes
  unconditionally as described in 4404627.

NPE is reproducible when running the test with jtreg.
The cause is that DnDSource declares 'df' as transient.
The dropped button is a serialized copy of the original one, so its
'df' is null. This way getTransferDataFlavors() returns an array which
contains null element. NPE is thrown when DataTransferer tries to
dereference this field. 

To resolve it i suggest to move 'df' to non-transient.

After df is moved to non-transient, NPE is thrown at another location:

java.lang.NullPointerException
        at sun.awt.datatransfer.DataTransferer$1.getNativesForFlavors(DataTransferer.java:362)
        at sun.awt.datatransfer.DataTransferer$1.getNativesForFlavor(DataTransferer.java:368)
        at sun.awt.datatransfer.DataTransferer.getFormatsForFlavors(DataTransferer.java:499)
        at sun.awt.datatransfer.DataTransferer.getFormatsForTransferable(DataTransferer.java:453)
        at sun.awt.dnd.SunDragSourceContextPeer.startDrag(SunDragSourceContextPeer.java:93)
        at java.awt.dnd.DragSource.startDrag(DragSource.java:297)
        at java.awt.dnd.DragSource.startDrag(DragSource.java:394)
        at java.awt.dnd.DragGestureEvent.startDrag(DragGestureEvent.java:196)
        at DnDSource.dragGestureRecognized(DnDSource.java:44)
        at java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(DragGestureRecognizer.java:345)
        at MyMouseDragGestureRecognizer.mousePressed(MyMouseDragGestureRecognizer.java:32)
        at java.awt.Component.processMouseEvent(Component.java:4859)
        at java.awt.Component.processEvent(Component.java:4688)
        at java.awt.Button.processEvent(Button.java:330)
        at java.awt.Component.dispatchEventImpl(Component.java:3460)
        at java.awt.Component.dispatchEvent(Component.java:3327)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:439)
        at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:150)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:131)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

It is thrown, since DragSource.flavorMap is transient and so
getFlavorMap() returns null for a serialized copy of the original
DataFlavor. NPE is thrown when DataTransferer tries to access the map.

###@###.### 2001-03-14

======================================================================
                                     
2001-03-14
SUGGESTED FIX



Name: dsR10078			Date: 03/14/2001



To resolve crashes:
Disable the Motif default drag support for all widgets.

To resolve NPE:
Write out flavor map of the DragSource being serialized and read it
on deserialization of DragSource. If we read null flavor map
initialize flavor map with SystemFlavorMap.getDefaultFlavorMap().

###@###.### 2001-03-14

======================================================================
                                     
2001-03-14
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
merlin-beta

FIXED IN:
merlin-beta

INTEGRATED IN:
merlin-beta

VERIFIED IN:
merlin-rc1


                                     
2004-06-14



Hardware and Software, Engineered to Work Together