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

XDnDDropTargetProtocol throwing exception incorrectly

XMLWordPrintable

    • x86
    • linux_ubuntu

      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"

            pchelko Petr Pchelko (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: