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

Drag and drop file to TextComponent times, it would block to die

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Version:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10
      java version "1.8.0_291"
      Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
      Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      On Windows 10 with chinese ime(I am not sure other language versions have same question), Drag and drop file to TextComponent, about 5-10 times, the whole java app would block to die.

      REGRESSION : Last worked in version 8

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1, Startup Test Code.
      2, Drag a file to yellow area and drop. The file name would add to yellow area.
      3, Repeatly for 10 times.
      If the bug not ocurred, then exit app and restart again.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Drap and drop works OK, and the file name always add to yellow area.
      ACTUAL -
      Some times the whole app would blocked, And you can do nothing but kill it.

      ---------- BEGIN SOURCE ----------
      package taishan;

      import java.awt.Color;
      import java.awt.datatransfer.DataFlavor;
      import java.awt.dnd.DropTarget;
      import java.awt.dnd.DropTargetDropEvent;

      import javax.swing.JEditorPane;
      import javax.swing.JFrame;

      @SuppressWarnings("serial")
      public class DndTest extends JEditorPane
      {
          
      private static DndTest mEditor;

          public DndTest()
          {
           this.setBackground(Color.YELLOW);
          }
          
          public static class DragDropListener extends DropTarget
          {
              public DragDropListener(java.awt.Component component)
              {
                  super();
                  setComponent(component);
              }

              @Override
              public void dragEnter(java.awt.dnd.DropTargetDragEvent dtde)
              {
               //System.out.println("dragEnter()");
                  super.dragEnter(dtde);
              }

              @Override
              public synchronized void dragOver(java.awt.dnd.DropTargetDragEvent dtde)
              {
                  //System.out.println("dragOver()");
              }

              @Override
              public void dragExit(java.awt.dnd.DropTargetEvent event)
              {
              }

              @Override
              public void drop(DropTargetDropEvent e)
              {
               //System.out.println("drop()");
                  e.acceptDrop(e.getDropAction());
                  DataFlavor[] flavors = e.getTransferable().getTransferDataFlavors();
                  for (DataFlavor flavor : flavors)
                  {
                   if (flavor.equals(DataFlavor.javaFileListFlavor))
                   {
                   try
                   {
                   mEditor.setText(
                   mEditor.getText()
                   + "\n"
                   + e.getTransferable().getTransferData(flavor));
                   }
                   catch (Exception excep)
                   {
                   excep.printStackTrace();
                   }
                          break;
                   }
                  }
                  
                  e.dropComplete(false);
                  return;
                  //e.rejectDrop();
              }

          }
              
              
              
          public static void main(String[] args)
          {
              JFrame frame = new JFrame();
              frame.setSize(800, 500);

              mEditor = new DndTest();
              mEditor.setText("Taishan Office");
              new DndTest.DragDropListener(mEditor);
              
              frame.getContentPane().add(mEditor);
              
              frame.setVisible(true);
              
          }
          
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      I have found two solutions for this bug.
      1, awt_InputMethod.cpp Java_sun_awt_windows_WInputMethod_openCandidateWindow():
      comment the InvokeInputMethodFunction()
      2, awt_Toolkit.cpp InvokeInputMethodFunction:
      modify it like this:
      ::WaitForSingleObject(m_inputMethodWaitEvent,
                      msg == WM_AWT_OPENCANDIDATEWINDOW ? 10 : INFINITE);

      FREQUENCY : occasionally


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              alitvinov Anton Litvinov
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated: