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

Robot process exits unexpectedly on Linux

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs
    • x86
    • linux

      Name: dsR10078 Date: 06/15/2001

      ###@###.###

      This bug is reproducible on Linux with merlin build b67 and earlier.
      If a thread stops just after making a request to Robot, the Robot
      child process may exit before processing the request, so that the
      requested native event is not generated.

      Here is the test case that reproduces the problem:
      ------------------------------------------------------------------------
      import java.awt.*;
      import java.awt.event.*;

      public class Test extends MouseAdapter implements Runnable {
          final Frame frame = new Frame();
          final Dialog dialog = new Dialog(frame, true);
          final Thread thread = new Thread(this);
          
          public static void main(String[] args) {
              new Test();
          }

          public Test() {
              dialog.setBounds(200, 200, 200, 200);
              dialog.addMouseListener(this);
              thread.start();
              dialog.setVisible(true);
          }
          
          public void run() {
              try {
                  final Robot robot = new Robot();
                  Thread.sleep(1000);
                  
                  final Point srcPoint = dialog.getLocationOnScreen();
                  final Dimension d = dialog.getSize();
                  srcPoint.translate(d.width / 2, d.height / 2);
                  
                  robot.mouseMove(srcPoint.x, srcPoint.y);
                  robot.mousePress(InputEvent.BUTTON1_MASK);
                  for (int i = 0; i < 50; i++) {
                      robot.mouseMove(srcPoint.x + i, srcPoint.y);
                      Thread.sleep(20);
                  }
                  robot.mouseRelease(InputEvent.BUTTON1_MASK);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }

          public void mousePressed(MouseEvent e) {
              System.err.println(e);
          }

          public void mouseReleased(MouseEvent e) {
              System.err.println(e);
          }
      }
      ------------------------------------------------------------------------
      Run the test case. A modal dialog will appear. The robot presses the mouse
      button, drags and then releases the mouse button.

      On Linux the debug output indicates that button release event may be not
      generated in response to robot request. The test works correctly on Solaris
      and Windows.

      This happens as the robot child process exits when the parent process
      exits. On Linux each Java thread is implemented as a separate process,
      so if the Java thread that created Robot exits, the robot child
      process exits as well.

      ======================================================================

            denis Denis Fokin (Inactive)
            dassunw Das Das (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: