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

java hangs after drop

XMLWordPrintable

    • beta
    • generic, x86
    • windows_95, windows_98, windows_nt



      Name: diC59631 Date: 12/09/98


      To reproduce, start DropBug, drag the red rectangle
      and drop it onto the green one, afterwards: java is "not responding".
      A thread dump is included after the source.

      // Source:
      import java.io.*;
      import java.awt.*;
      import java.awt.event.*;
      import java.awt.dnd.*;
      import java.awt.datatransfer.*;
      import javax.swing.*;

      class DropBug extends JFrame
      {
      DropBug()
      {
      super("Drag red rectangle and drop it on green one");
      JPanel p1 = new JPanel();
      p1.setSize(100, 100);
      p1.add(new DragMe());
      getContentPane().add(p1);
      JPanel p2 = new JPanel();
      p2.add(new DropHere(p2));
      p2.setSize(100, 100);
      getContentPane().add(p2);
      setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
      p1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      p2.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      pack();
      setSize(600, 400);
      show();
      }
      public static void main(String args[])
      {
      new DropBug();
      }
      public static final DataFlavor dataFlavor = new DataFlavor(DragMe.class, "AAP");
      class DragMe extends JComponent implements DragGestureListener, DragSourceListener, Transferable, Serializable
      {
      DragMe()
      {
      DragSource source = DragSource.getDefaultDragSource();
      source.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, this);
      }
      public void dropActionChanged(DragSourceDragEvent dsde){}
      public void dragEnter(DragSourceDragEvent dsde){}
      public void dragOver(DragSourceDragEvent dsde){}
      public void dragGestureChanged(DragSourceDragEvent dsde){}
      public void dragExit(DragSourceEvent dse){}
      public void dragDropEnd(DragSourceDropEvent dsde)
      {
      }
      public void dragGestureRecognized(DragGestureEvent dge)
      {
      dge.startDrag(null, this, this);
      }
      public DataFlavor[] getTransferDataFlavors()
      {
      DataFlavor[] flavors = new DataFlavor[1];
      flavors[0] = dataFlavor;
      return flavors;
      }
      public boolean isDataFlavorSupported(DataFlavor flavor)
      {
      return flavor.equals(dataFlavor);
      }
      public Object getTransferData(DataFlavor flavor)
      throws UnsupportedFlavorException, IOException
      {
      return "Aap";;
      }
      public Dimension getPreferredSize()
      {
      return new Dimension(50, 50);
      }
      public void paint(Graphics g)
      {
      Rectangle rec = getBounds();
      g.setColor(Color.red);
      g.fill3DRect(0, 0, rec.width, rec.height, true);
      }
      }
      class DropHere extends JComponent implements MouseMotionListener, DropTargetListener
      {
      JPanel parent;
      boolean ok = false;

      DropHere(JPanel parent)
      {
      this.parent = parent;
      parent.addMouseMotionListener(this);
      new DropTarget(this, DnDConstants.ACTION_COPY, this, true);
      }
      public Dimension getPreferredSize()
      {
      return new Dimension(60, 60);
      }
      public void paint(Graphics g)
      {
      Rectangle rec = getBounds();
      g.setColor(Color.green);
      g.fill3DRect(0, 0, rec.width, rec.height, true);
      }
      public void mouseDragged(MouseEvent e){}
      public void mouseMoved(MouseEvent e){}
      public void mouseEntered(MouseEvent e){}
      {
      }
      public void mouseExited(MouseEvent e)
      {
      synchronized(parent)
      {
      parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      }
      }
      public void dropActionChanged(DropTargetDragEvent dtde){}
      public void dragEnter(DropTargetDragEvent dtde)
      {
      DataFlavor flavor[] = dtde.getCurrentDataFlavors();

      for (int i=0; i<flavor.length; i++)
      {
      if (flavor[i].equals(dataFlavor))
      {
      System.out.println("Accept");
      dtde.acceptDrag(DnDConstants.ACTION_COPY);

      return;
      }
      }

      dtde.rejectDrag();
      }
      public void dragOver(DropTargetDragEvent dtde){}
      public void dragScroll(DropTargetDragEvent dtde){}
      public void dragExit(DropTargetEvent dte){}
      public void drop(DropTargetDropEvent dtde)
      {
      dtde.acceptDrop(DnDConstants.ACTION_COPY);
      Transferable transferable = dtde.getTransferable();
      DataFlavor flavors[] = dtde.getCurrentDataFlavors();

      String s =null;

      try
      {
      for (int i = 0; i < flavors.length; i++)
      {
      if (flavors[i].equals(dataFlavor))
      {
      s = (String) transferable.getTransferData(flavors[i]);
      System.out.println("Received "+s);

      break;
      }
      }
      }
      catch (Throwable t)
      {
      }
      finally
      {
      dtde.getDropTargetContext().dropComplete(true);
      }
      }
      }
      }

      /////////


      Full thread dump Classic VM (JDK-1.2-V, native threads):
          "Thread-1" (TID:0xd62f7d8, sys_thread_t:0x8d4ce0, state:R, native ID:0xcf) prio=6
      at sun.awt.windows.WDragSourceContextPeer.doDragDrop(Native Method)
      at sun.awt.windows.WDragSourceContextPeer$1.run(WDragSourceContextPeer.java:163)
          "Thread-0" (TID:0xd62d830, sys_thread_t:0x8cc4e0, state:CW, native ID:0xf1) prio=5
          "AWT-Windows" (TID:0xd61d108, sys_thread_t:0x888310, state:CW, native ID:0xce) prio=5
      at java.lang.Object.wait(Native Method)
      at java.lang.Object.wait(Compiled Code)
      at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1149)
      at sun.awt.windows.WDragSourceContextPeerDispatcher.dispatch(Compiled Code)
      at sun.awt.windows.WDragSourceContextPeerDispatcher.deliverDropFinish(WDragSourceContextPeer.java:534)
      at sun.awt.windows.WDragSourceContextPeer.dragDropFinished(WDragSourceContextPeer.java:374)
      at sun.awt.windows.WToolkit.eventLoop(Native Method)
      at sun.awt.windows.WToolkit.run(WToolkit.java:134)
      at java.lang.Thread.run(Thread.java:479)
          "SunToolkit.PostEventQueue-0" (TID:0xd61cf68, sys_thread_t:0x888180, state:CW, native ID:0xe5) prio=5
      at java.lang.Object.wait(Native Method)
      at java.lang.Object.wait(Compiled Code)
      at sun.awt.PostEventQueue.run(SunToolkit.java:363)
          "AWT-EventQueue-0" (TID:0xd61cf98, sys_thread_t:0x887de0, state:R, native ID:0xe9) prio=6
      at sun.awt.windows.WComponentPeer.setCursor(Native Method)
      at java.awt.Component.setCursor(Component.java:1759)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Compiled Code)
      at java.awt.LightweightDispatcher.trackMouseEnterExit(Compiled Code)
      at java.awt.LightweightDispatcher.processMouseEvent(Compiled Code)
      at java.awt.LightweightDispatcher.dispatchEvent(Compiled Code)
      at java.awt.Container.dispatchEventImpl(Compiled Code)
      at java.awt.Window.dispatchEventImpl(Compiled Code)
      at java.awt.Component.dispatchEvent(Compiled Code)
      at java.awt.EventQueue.dispatchEvent(Compiled Code)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:68)
          "Finalizer" (TID:0xd5f9320, sys_thread_t:0x820460, state:CW, native ID:0xfd) prio=8
      at java.lang.Object.wait(Native Method)
      at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:112)
      at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
      at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:174)
          "Reference Handler" (TID:0xd5f93b0, sys_thread_t:0x81f800, state:CW, native ID:0xfc) prio=10
      at java.lang.Object.wait(Native Method)
      at java.lang.Object.wait(Object.java:424)
      at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:114)
          "Signal dispatcher" (TID:0xd5f93e0, sys_thread_t:0x81edb0, state:R, native ID:0xef) prio=5
      Monitor Cache Dump:
          sun.awt.windows.WDragSourceContextPeerDispatcher@D61D0A0/DA19C98: owner "AWT-Windows" (0x888310) 1 entry
          sun.awt.windows.WFramePeer@D62D660/DAC2070: owner "AWT-EventQueue-0" (0x887de0) 1 entry
          java.lang.ref.ReferenceQueue$Lock@D5F9338/D92F028: <unowned>
      Waiting to be notified:
      "Finalizer" (0x820460)
          sun.awt.PostEventQueue@D61CF68/DA18C00: <unowned>
      Waiting to be notified:
      "SunToolkit.PostEventQueue-0" (0x888180)
          javax.swing.SwingUtilities$1@D630558/DBAA640: <unowned>
      Waiting to be notified:
      "AWT-Windows" (0x888310)
          java.lang.ref.Reference$Lock@D5F93C0/D92EB20: <unowned>
      Waiting to be notified:
      "Reference Handler" (0x81f800)
          DropBug@D6098B0/D9A6C08: owner "AWT-EventQueue-0" (0x887de0) 1 entry
      Registered Monitor Dump:
          SymcJIT Method Monitor: <unowned>
          SymcJIT Method Monitor: <unowned>
          SymcJIT Method List Monitor: <unowned>
          SymcJIT Lock: <unowned>
          utf8 hash table: <unowned>
          JNI pinning lock: <unowned>
          JNI global reference lock: <unowned>
          BinClass lock: <unowned>
          Class linking lock: <unowned>
          System class loader lock: <unowned>
          Code rewrite lock: <unowned>
          Heap lock: <unowned>
          Monitor cache lock: owner "Signal dispatcher" (0x81edb0) 1 entry
          Thread queue lock: owner "Signal dispatcher" (0x81edb0) 1 entry
      Waiting to be notified:
      (Review ID: 47638)
      ======================================================================

      The attached sample program also failed on Win'98 on the jdk kestrel-beta
      release (Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-J)
      Roger Pham 10/12/99

      Since this bug is causing the JCK regression tests to fail, I'm upgrading
      it status to red.

      Roger Pham 10/12/99

            dmendenhsunw David Mendenhall (Inactive)
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: