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

Hotspot EXCEPTION_ACCESS_VIOLATION using invokeLater on a DragGestureEvent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.3.0
    • client-libs
    • beta2
    • x86
    • windows_nt, windows_2000



      Name: stC104175 Date: 07/18/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      When I try to use the invokeLater() method on a DragGestureEvent (so as to allow
      row selection to take priority over the dragging), the hotspot virtual machine
      exits with :
      # HotSpot Virtual Machine Error, EXCEPTION_ACCESS_VIOLATION
      # Error ID: 4F533F57494E13120E43505002D4

      The actual line of code causing the problem is :
              event.startDrag (DragSource.DefaultCopyNoDrop,new
      StringSelection("Test"),TestTable2.this);

      Here is a test program which causes the probem :

      import java.awt.*;
      import java.awt.dnd.*;
      import javax.swing.*;
      import java.awt.datatransfer.*;
      import javax.swing.table.*;

      public class TestTable2 extends JTable
      implements DragSourceListener, DragGestureListener
      {
        DragSource dragSource;
        DragGestureRecognizer dgr;
        public TestTable2(){
          dragSource = new DragSource ();
          dgr = dragSource.createDefaultDragGestureRecognizer (this,
                DnDConstants.ACTION_COPY_OR_MOVE, this);
        }
        
         public void dragGestureRecognized (DragGestureEvent e) {
           Runnable dragThread = new DragThread(e);
           SwingUtilities.invokeLater(dragThread);
         }

         public class DragThread implements Runnable {
           DragGestureEvent event;
           public DragThread(DragGestureEvent e){
             event = e;
           }
           public void run() {
              System.out.println("In Draging Thread " + Thread.currentThread());
              event.startDrag (DragSource.DefaultCopyNoDrop, new
      StringSelection("Test"),
                                    TestTable2.this);
              System.out.println("Exit Draging Thread " + Thread.currentThread());
           }
         }
         
         public void dragEnter (DropTargetDragEvent e) {
              e.acceptDrag (e.getDropAction());
         }

         public void dragDropEnd (DragSourceDropEvent e) {}
         public void dragEnter (DragSourceDragEvent e) {}
         public void dragExit (DragSourceEvent e) {}
         public void dragOver (DragSourceDragEvent e) {}
         public void dropActionChanged (DragSourceDragEvent e) {}
         public void dragExit (DropTargetEvent e) {}
         public void dragOver (DropTargetDragEvent e) {}
         
        //------TESTING-------
         static private int TEST_ROWS = 100;
         static private int TEST_COLS = 10;
         
         protected class TestTableModel
            extends DefaultTableModel
         {
           public TestTableModel () {
             super (TEST_ROWS, TEST_COLS);
             StringBuffer res;

             for (int r = 0; r < TEST_ROWS; r++) {
                for (int c = 0; c < TEST_COLS; c++) {
                   res = new StringBuffer ("V ");
                   res.append (r);
                   res.append (":");
                   res.append (c);
                   this.setValueAt (res.toString (), r, c);
                }
             }
           }
         }

         protected class TestWindowListener
            extends java.awt.event.WindowAdapter
         {
            public void windowClosing (java.awt.event.WindowEvent e) {
               System.exit (0);
            }
         }
         
         public static void main (String args[]) {
           TestTable2 tmpTable = new TestTable2();
           tmpTable.setModel(tmpTable.new TestTableModel());
           tmpTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
           javax.swing.JFrame frame = new JFrame ();
           JScrollPane scrPane = new JScrollPane(tmpTable);
           
      scrPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
           
      scrPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)
      ;
           frame.setSize (new Dimension (450, 400));
           frame.addWindowListener (tmpTable.new TestWindowListener ());
           frame.getContentPane ().setLayout (new java.awt.BorderLayout());
           frame.getContentPane ().add (scrPane,BorderLayout.CENTER);
           frame.show ();
         }
      }
      (Review ID: 107325)
      ======================================================================

      Name: rl43681 Date: 08/07/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      #
      # HotSpot Virtual Machine Error, EXCEPTION_ACCESS_VIOLATION
      # Please report this error at
      # http://java.sun.com/cgi-bin/bugreport.cgi
      #
      # Error ID: 4F533F57494E13120E43505002D4
      #

      I am calling dragGestureRecognized.

      Note: I am doing this as a work around to a problem that I don't know how to
      fix. My application contains JButtons that I have made into Drag and Drop
      components. However, I still need the buttons to work like buttons (to handle
      an action event when the user mouse clicks on it.) The first time I click on
      the button after I bring up my application a drag gesture is recognized (even
      though I am not initiated a drag gesture by dragging the mouse.) After the
      first time it does not happen again.

      This really screws up my application and thus I am trying to work around the
      problem. However, I have run into A LOT of stuff like this using Drag and Drop
      (I have had to code a lot of hacks and work-arounds to get this to work
      correctly.) Needless to say, I am extremely tired and frustrated with Drag and
      Drop and wish that we could take it out of our application - unfortunately, due
      to customer demand, we cannot.

      Yes bug 4354044 in Bug Parade describes the problem I encountered last weekend (sorry
      for leading you astray on a bug that you already know about.) Let me
      explain more carefully what I was really trying to report (I encountered the
      VM error while attempting to find a work-around for the original problem.)

      The original problem is that when I first bring up my application and I try
      to click on a button (that I have also created as a draggable component) a
      drag gesture is initiated. The drag is initiated even though I DID NOT drag
      the cursor - I only single clicked on the button. After the first click on
      the button this problem does not happen again. (BTW - all this is happening
      on components that are nested within JInternalFrames.)

      I originally was trying to use the Robot class as a work around (to
      pre-emptively do a drag and drop before the user could see the problem.)
      This was a horrible hack, and I could not get it to come out very stable.
      So I ended up toggling the visibility of the internal frame that contains
      the button, when that frame is first shown. This works but is also a
      horrific hack (and turns out I can't do this anyway because my boss has
      deamed this to be unacceptable behavior for our product.)

      So I'm back to square one on this. That's the problem. If there's anymore
      you need to know feel free to ask.
      (Review ID: 108025)
      ======================================================================

            ibdsunw Ibd Ibd (Inactive)
            stompkinsunw Sean Tompkins (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: