JDK-7100524 : XDnDDropTargetProtocol throwing exception incorrectly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7,8
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux_ubuntu
  • CPU: x86
  • Submitted: 2011-10-13
  • Updated: 2014-05-27
  • Resolved: 2014-05-27
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.
JDK 9
9Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Server VM (build 21.0-b17, mixed mode)
(Occurs on all versions from 1.6.0-23 to present)

ADDITIONAL OS VERSION INFORMATION :
Ubuntu 10.04
2.6.32-34-generic #77-Ubuntu SMP Tue Sep 13 19:40:53 UTC 2011 i686 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
Identical bug described in the following ticket.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7027598
The ticket was incorrectly marked as "Not a Defect" and was closed.  The bug continues to persist.

REGRESSION.  Last worked in version 5.0

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The bug can be reliably reproduced using test code submitted by cptn_carrot in ticked 7027598.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception thrown.
ACTUAL -
Exception thrown

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" sun.awt.X11.XException: Cannot write XdndAware property
	at sun.awt.X11.XDnDDropTargetProtocol.registerDropTarget(XDnDDropTargetProtocol.java:79)
	at sun.awt.X11.XDropTargetRegistry.registerDropSite(XDropTargetRegistry.java:554)
	at sun.awt.X11.XWindowPeer.addDropTarget(XWindowPeer.java:1633)
	at sun.awt.X11.XComponentPeer.addDropTarget(XComponentPeer.java:1509)
	at java.awt.dnd.DropTarget.addNotify(DropTarget.java:493)
	at java.awt.Component.addNotify(Component.java:6687)
	at java.awt.Container.addNotify(Container.java:2567)
	at javax.swing.JComponent.addNotify(JComponent.java:4685)
	at java.awt.Container.addImpl(Container.java:1068)
	at java.awt.Container.add(Container.java:365)
	at TestFrame$1.run(TestFrame.java:34)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
	at java.awt.EventQueue.access$000(EventQueue.java:84)
	at java.awt.EventQueue$1.run(EventQueue.java:602)
	at java.awt.EventQueue$1.run(EventQueue.java:600)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

REPRODUCIBILITY :
This bug can be reproduced often.

---------- BEGIN SOURCE ----------
import java.awt.Container;
import java.awt.EventQueue;
import java.awt.Window;
import java.awt.peer.ComponentPeer;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JTextField;

import sun.awt.X11.XBaseWindow;
import sun.awt.X11.XToolkit;


public class TestFrame extends JFrame {
		public static void main(String[] args) throws Exception {
			EventQueue.invokeLater(new Runnable() {
				public void run() {
					TestFrame frame = new TestFrame();
					frame.pack();
					frame.setVisible(true);
					JDialog dialog = new JDialog(frame,"title",true);
					Container content = dialog.getContentPane();
					dialog.pack();
					JTextField text = new JTextField("bla");
					// generate X Error directly before adding the textfield
					generateXErrorSafe(dialog);
					// with the next call the dialog is activating itself as DropTarget for X
					content.add(text);
					// the next two lines are never reached
					dialog.pack();
					dialog.setVisible(true);
				}
			});
			Thread.sleep(8000);
			System.exit(0);
		}

		static void directResize(long windowId, int w, int h) {
			try {
				XToolkit.awtLock();
				Method xresizeWindow = Class.forName("sun.awt.X11.XlibWrapper").getDeclaredMethod("XResizeWindow", long.class, long.class, int.class, int.class);
				xresizeWindow.setAccessible(true);
				xresizeWindow.invoke(null, new Object[]{getXDisplay(), windowId, w, h});
			} catch (Exception e) {
				throw new RuntimeException(e);
			} finally {
				XToolkit.awtUnlock();
			}
		}

		static long getXDisplay() {
			try {
				Method getDisplay = XToolkit.class.getDeclaredMethod("getDisplay");
				getDisplay.setAccessible(true);
				return (Long)getDisplay.invoke(null, new Object[]{});
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}

		static long extractWindow(ComponentPeer peer) {
			try {
				Field field = XBaseWindow.class.getDeclaredField("window");
				field.setAccessible(true);
				return (Long)field.get(peer);
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}

		static void generateXErrorSafe(Window dialog) {
			ComponentPeer peer = dialog.getPeer();
			long windowId = extractWindow(peer);
			int w=Integer.MIN_VALUE;
			int h=Integer.MAX_VALUE;
			for(int i=0;i<5000;i++) {
				directResize(windowId, w, h);
			}
		}

	
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
start the VM with "-DsuppressSwingDropSupport=true"

Comments
These are all approved for deferral to JDK 9 so you can update the FixVersion to state JDK 9. Kind regards, Mathias
29-08-2013

These are all approved for deferral to JDK 9 so you can update the FixVersion to state JDK 9. Kind regards, Mathias
29-08-2013

These are all approved for deferral to JDK 9 so you can update the FixVersion to state JDK 9. Kind regards, Mathias
29-08-2013

sqe bugs: GS-Tonga/DnDTest/ja_DnDTextTest GS-Tonga/DnDTest/ko_DnDTextTest GS-Tonga/DnDTest/zh_CN_DnDTextTest GS-Tonga/DnDTest/zh_TW_DnDTextTest
19-08-2013

Converted "8-client-defer-candidate" label to "8-defer-request" by SQE' OK.
15-08-2013

*This is anti-deferral criteria list*: - P2 -------------- Engineering's Criteria ------------------------------------- - tck-red labeled - conformance labeled - P3 regressions reported/labeled against jdk8 - findbugs, parfait, eht labeled bugs - CAP <1 year reported - netbeans <1 year reported Victor ----------------- SQE's OK --------------------------------- Yes, we are ok with that thanks, Mikhail
15-08-2013

8-defer-request: This is the issue reproduced from 7 GA, this is not a regression in 8, requesting to defer because there are no customer escalations on this issue.
17-06-2013

Looks like a native system cannot handle properly such a big size. It might happen due XRenderer and OpenGL constrains. We had a similar issue on MacOS. But from my point of view, the problem more in the test than in the implementation. I think we still could constraint the max window size to something more realistic on AWT side.
18-03-2013

EVALUATION The problems from see also section should be verified after a fix for the current issue.
14-10-2011