JDK-8173803 : [macosx] Drag and drop not working
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8u72,9,10
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: os_x
  • CPU: x86
  • Submitted: 2017-02-01
  • Updated: 2019-03-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Mac OS Sierra 10.12.3

A DESCRIPTION OF THE PROBLEM :
Drag And Drop from one Java window to another does not work. 

If an object is dragged from one window to another window via drag and drop, the drag and drop action is not completed. The java application thinks it is still in the drag and drop. If one tries another drag and drop action an exception will be thrown: 'java.awt.dnd.InvalidDnDOperationException: Drag and drop in progress'. 

It is therefore no longer possible to drag and drop objects in this application. The problem occurs always at the transition between the drag source window and the drag target window. Working with the application is still possible. After a restart of the application, Drag And Drop will work again.

Furthermore, the system Dock becomes disabled and does not react to mouse events - it isn't possible to switch to other windows by clicking their Dock icons. Popup menu on the Dock doesn't work either. Switching to other apps with keyboard works fine though. After quitting the application in broken drag mode, the Dock becomes responsive again. 

The Error occurs in: CDragSourceContextPeer.doDragging(long). This is a native method, which is implemented in the JRE. The Callstack of the corresponding thread:

Thread [Thread-29]
   CDragSourceContextPeer.doDragging(long) line: not available [native method]
   CDragSourceContextPeer.access$100(CDragSourceContextPeer, long) line 49
   CDragSourceContextPeer$1.run() line: 170

This error is similar to the reported error JDK-7177144 but in this case it is a genuine Java application and not netbeans. Maybe the error JDK-7185258 is the reason for this problem.

The Stacktrace of the threads (suspended in eclipse - but error occurs outside IDE as well):

ApplicationCore18 [Java Application]	
	com.heidelberg.signa.main.SignaMain at localhost:60994 (Suspended)	
		Daemon System Thread [Signal Dispatcher] (Suspended)	
		Daemon System Thread [Finalizer] (Suspended)	
		Daemon System Thread [Reference Handler] (Suspended)	
		Daemon System Thread [JavaFX Application Thread] (Suspended)	
			LWCToolkit.doAWTRunLoopImpl(long, boolean, boolean) line: not available [native method]	
			LWCToolkit.doAWTRunLoop(long, boolean) line: 825	
			CToolkitThreadBlockedHandler.enter() line: 46	
			CDropTargetContextPeer(SunDropTargetContextPeer).postDropTargetEvent(Component, int, int, int, int, long[], long, int, boolean) line: 584	
			CDropTargetContextPeer.postDropTargetEvent(Component, int, int, int, int, long[], long, int, boolean) line: 165	
			CDropTargetContextPeer(SunDropTargetContextPeer).handleExitMessage(Component, long) line: 359	
		Daemon System Thread [process reaper] (Suspended)	
		Daemon Thread [Timer-0] (Suspended)	
		System Thread [AWT-Shutdown] (Suspended)	
		Thread [AWT-EventQueue-0] (Suspended)	
			Unsafe.park(boolean, long) line: not available [native method]	
			LockSupport.park(Object) line: 175	
			AbstractQueuedSynchronizer$ConditionObject.await() line: 2039	
			EventQueue.getNextEvent() line: 554	
			EventDispatchThread.pumpOneEventForFilters(int) line: 170	
			EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: 116	
			EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: 105	
			EventDispatchThread.pumpEvents(int, Conditional) line: 101	
			EventDispatchThread.pumpEvents(Conditional) line: 93	
			EventDispatchThread.run() line: 82	
		Daemon System Thread [Java2D Queue Flusher] (Suspended)	
			waiting for: OGLRenderQueue$QueueFlusher  (id=33)	
			Object.wait(long) line: not available [native method]	
			OGLRenderQueue$QueueFlusher.run() line: 203	
		Daemon System Thread [Java2D Disposer] (Suspended)	
			waiting for: ReferenceQueue$Lock  (id=114)	
			Object.wait(long) line: not available [native method]	
			ReferenceQueue<T>.remove(long) line: 143	
			ReferenceQueue<T>.remove() line: 164	
			Disposer.run() line: 148	
			Thread.run() line: 745	
		Daemon Thread [QuantumRenderer-0] (Suspended)	
		Daemon Thread [Thread-6] (Suspended)	
		Daemon Thread [Thread-7] (Suspended)	
		Daemon System Thread [Prism Font Disposer] (Suspended)	
		Thread [ApplicationAction-Thread] (Suspended)	
		Thread [Thread-9] (Suspended)	
		Thread [Timer-1] (Suspended)	
		Daemon Thread [Timer runner-1,Remote_Update_Channel_Signa_Station-18_kie-haasetim-mc.ppe.kie.de.heidelberg.com,kie-haasetim-mc-59142] (Suspended)	
		Thread [TransferQueueBundler,Remote_Update_Channel_Signa_Station-18_kie-haasetim-mc.ppe.kie.de.heidelberg.com,kie-haasetim-mc-59142] (Suspended)	
		Thread [unicast receiver,Remote_Update_Channel_Signa_Station-18_kie-haasetim-mc.ppe.kie.de.heidelberg.com,kie-haasetim-mc-59142] (Suspended)	
		Thread [multicast receiver,Remote_Update_Channel_Signa_Station-18_kie-haasetim-mc.ppe.kie.de.heidelberg.com,kie-haasetim-mc-59142] (Suspended)	
		Daemon Thread [WatchThread - 1033638837] (Suspended)	
		Thread [AutoGang] (Suspended)	
		Daemon Thread [FolderWatcher - 640808588] (Suspended)	
		Daemon System Thread [TimerQueue] (Suspended)	
		Daemon Thread [SwingWorker-pool-6-thread-1] (Suspended)	
		Thread [SignaPDF-(1)] (Suspended)	
		Thread [SignaPDF-(2)] (Suspended)	
		Thread [SignaPDF-(3)] (Suspended)	
		Thread [SignaPDF-(0)] (Suspended)	
		Thread [SignaPDF-(4)] (Suspended)	
		Daemon Thread [Thread-21] (Suspended)	
		Daemon System Thread [RMI TCP Accept-0] (Suspended)	
		System Thread [RMI Reaper] (Suspended)	
		Daemon System Thread [GC Daemon] (Suspended)	
		Daemon System Thread [RMI Scheduler(0)] (Suspended)	
		Thread [DestroyJavaVM] (Suspended)	
		Thread [RMI-Rebind-Thread] (Suspended)	
		Thread [Doc_1_1485941334042-Thread] (Suspended)	
		Thread [DirectImageManager(0)] (Suspended)	
		Thread [DirectImageManager(1)] (Suspended)	
		Thread [DirectImageManager(2)] (Suspended)	
		Thread [DirectImageManager(3)] (Suspended)	
		Thread [DirectImageManager(4)] (Suspended)	
		Daemon Thread [SwingWorker-pool-6-thread-2] (Suspended)	
		Daemon Thread [Timer-2,Remote_Update_Channel_Signa_Station-18_kie-haasetim-mc.ppe.kie.de.heidelberg.com,kie-haasetim-mc-59142] (Suspended)	
		Thread [Thread-29] (Suspended)	
			CDragSourceContextPeer.doDragging(long) line: not available [native method]	
			CDragSourceContextPeer.access$100(CDragSourceContextPeer, long) line: 49	
			CDragSourceContextPeer$1.run() line: 170	
		Daemon Thread [Timer-3,Remote_Update_Channel_Signa_Station-18_kie-haasetim-mc.ppe.kie.de.heidelberg.com,kie-haasetim-mc-59142] (Suspended)	
	/Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk/Contents/Home/bin/java (01.02.2017, 10:27:42)	





STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
A Java appliction with two windows. Drag from one window and drop to the other window. In some cases the drag and drop will not complete successfully. 

To reproduce it is necessary to drag and drop the object multiple times. After that it will occur while dragging the object at the transition from the dragsource window to the dragtarget window.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The dragging should complete successfully.
ACTUAL -
The dragging hangs and drag and drop is no longer possible after the error occurs.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
After the error occurs the next drag and drop will throw the following exception: 'java.awt.dnd.InvalidDnDOperationException: Drag and drop in progress'.

REPRODUCIBILITY :
This bug can be reproduced often.

CUSTOMER SUBMITTED WORKAROUND :
Close the application and restart it. After restart drag and drop works again.


Comments
Checked this with JDK 10 b26 and the issue is still reproducible.
11-10-2017

Please recheck this bug on jdk10b23 or later. There are a few related bugs were fixed: JDK-8153871, JDK-8136999 and JDK-8186263.
08-09-2017

Reopening this report with added information including test case and results from JDK-8187304. ======================= According to the description, Drag And Drop from one Java window to another does not work. This is a subsequent to JDK-8173803 with a test case. The default expected behavior where the Drag and Drop from one Java window to another does not work, when checked with respective JDK versions (see below). Results (MAC OS X 10.12.5) ================= 8u72: FAIL 8u144: FAIL 8u152 ea b05: FAIL 9 ea b152 b05: FAIL ================
07-09-2017

According to Submitter, I will write a little Test application so you can reproduce the issue. I��ll be back to you once I finished it.
06-02-2017

Description is incomplete as the testcase created from inputs received from description was unable to reproduce the issue. Recommend provision of a test case to ensure this is an issue by the webbug creator for possibility of triaging this as an issue to be fixed.
06-02-2017

Using a test case created by client-dev team from inputs received from description: import java.awt.Component; import java.awt.Container; import java.awt.Cursor; import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.dnd.DnDConstants; import java.awt.dnd.DragGestureEvent; import java.awt.dnd.DragGestureListener; import java.awt.dnd.DragGestureRecognizer; import java.awt.dnd.DragSource; import java.awt.dnd.DragSourceContext; import java.awt.dnd.DragSourceDragEvent; import java.awt.dnd.DragSourceDropEvent; import java.awt.dnd.DragSourceEvent; import java.awt.dnd.DragSourceListener; import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetEvent; import java.awt.dnd.DropTargetListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class MouseDragActionPanel extends JPanel implements MouseMotionListener { private static final int squareWidth = 25; private static final int max = 100; private static final int labelCount = 50; private Rectangle[] squares = new Rectangle[max]; private int squareCount = 0; private int currentSquareIndex = -1; boolean dragging; public MouseDragActionPanel() { addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) { int x = evt.getX(); int y = evt.getY(); currentSquareIndex = getSquare(x, y); if (currentSquareIndex < 0) { add(x, y); } } public void mouseClicked(MouseEvent evt) { int x = evt.getX(); int y = evt.getY(); if (evt.getClickCount() >= 2) { remove(currentSquareIndex); } } }); addMouseMotionListener(this); } public void paintComponent(Graphics g) { super.paintComponent(g); for (int i = 0; i < squareCount; i++) { ((Graphics2D) g).draw(squares[i]); } } public int getSquare(int x, int y) { for (int i = 0; i < squareCount; i++) { if (squares[i].contains(x, y)) { return i; } } return -1; } public void add(int x, int y) { if (squareCount < max) { squares[squareCount] = new Rectangle(x, y, squareWidth, squareWidth); currentSquareIndex = squareCount; squareCount++; repaint(); } } public void remove(int n) { if (n < 0 || n >= squareCount) { return; } squareCount--; squares[n] = squares[squareCount]; if (currentSquareIndex == n) { currentSquareIndex = -1; } repaint(); } public void mouseMoved(MouseEvent evt) { int x = evt.getX(); int y = evt.getY(); if (getSquare(x, y) >= 0) { setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } else { setCursor(Cursor.getDefaultCursor()); } } public void mouseDragged(MouseEvent evt) { int x = evt.getX(); int y = evt.getY(); if (currentSquareIndex >= 0) { Graphics g = getGraphics(); g.setXORMode(getBackground()); ((Graphics2D) g).draw(squares[currentSquareIndex]); squares[currentSquareIndex].x = x; squares[currentSquareIndex].y = y; ((Graphics2D) g).draw(squares[currentSquareIndex]); g.dispose(); } this.repaint(); } public static void main(String[] arg) { JLabel[] labels = new JLabel[100]; for (int i = 0; i < labelCount; i++) { labels[i] = new JLabel("label" + (i+1)); } JFrame source = new JFrame("Source Frame"); source.setLayout(new FlowLayout()); for (int i = 0; i < labelCount; i++) { source.add(labels[i]); } JFrame target = new JFrame("Target Frame"); target.setLayout(new FlowLayout()); DragDrop1 dndListener = new DragDrop1(); DragSource dragSource = new DragSource(); DropTarget dropTarget1 = new DropTarget(source, DnDConstants.ACTION_MOVE, dndListener); DropTarget dropTarget2 = new DropTarget(target, DnDConstants.ACTION_MOVE, dndListener); for (int i = 0; i < labelCount; i++) { DragGestureRecognizer dragRecognizer1 = dragSource.createDefaultDragGestureRecognizer(labels[i], DnDConstants.ACTION_MOVE, dndListener); } source.setBounds(0, 200, 400, 400); target.setBounds(420, 200, 400, 400); source.show(); target.show(); Container contentPane = target.getContentPane(); contentPane.add(new MouseDragActionPanel()); } } class DragDrop1 extends JPanel implements DragGestureListener, DragSourceListener, DropTargetListener, Transferable { static final DataFlavor[] supportedFlavors = {null}; static { try { supportedFlavors[0] = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType); } catch (Exception ex) { ex.printStackTrace(); } } Object object; // Transferable methods. public Object getTransferData(DataFlavor flavor) { if (flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) { return object; } else { return null; } } public DataFlavor[] getTransferDataFlavors() { return supportedFlavors; } public boolean isDataFlavorSupported(DataFlavor flavor) { return flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType); } // DragGestureListener method. public void dragGestureRecognized(DragGestureEvent ev) { ev.startDrag(null, this, this); } // DragSourceListener methods. public void dragDropEnd(DragSourceDropEvent ev) { } public void dragEnter(DragSourceDragEvent ev) { } public void dragExit(DragSourceEvent ev) { } public void dragOver(DragSourceDragEvent ev) { object = ev.getSource(); } public void dropActionchanged(DragSourceDragEvent ev) { } // DropTargetListener methods. public void dragEnter(DropTargetDragEvent ev) { } public void dragExit(DropTargetEvent ev) { } public void dragOver(DropTargetDragEvent ev) { dropTargetDrag(ev); } public void dropActionchanged(DropTargetDragEvent ev) { dropTargetDrag(ev); } void dropTargetDrag(DropTargetDragEvent ev) { ev.acceptDrag(ev.getDropAction()); } public void drop(DropTargetDropEvent ev) { ev.acceptDrop(ev.getDropAction()); try { Object target = ev.getSource(); Object source = ev.getTransferable().getTransferData(supportedFlavors[0]); Component component = ((DragSourceContext) source).getComponent(); Container oldContainer = component.getParent(); Container container = (Container) ((DropTarget) target).getComponent(); Point p = ev.getLocation(); component.setBounds(p.x, p.y, 24, 24); container.add(component); //oldContainer.validate(); //oldContainer.repaint(); container.validate(); container.repaint(); } catch (Exception ex) { ex.printStackTrace(); } ev.dropComplete(true); } @Override public void dropActionChanged(DragSourceDragEvent dsde) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void dropActionChanged(DropTargetDragEvent dtde) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }
06-02-2017

Requested submitter to send us a small test program with reproducible steps to reproduce it in-house.
06-02-2017

does it affect 9? 8 GA?
02-02-2017