JDK-4470419 : Robot process exits unexpectedly on Linux
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: linux
  • CPU: x86
  • Submitted: 2001-06-15
  • Updated: 2006-09-04
  • Resolved: 2006-09-04
Related Reports
Relates :  
Description
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.

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

Comments
EVALUATION After the fix for 6287244 the robot process is eliminated, so this bug doesn't take place anymore. Closing it as not reproducible.
04-09-2006

WORK AROUND Name: dsR10078 Date: 06/15/2001 ======================================================================
17-09-2004

EVALUATION Commit to fix in merlin-beta2 (serious problem with Robot). eric.hawkes@eng 2001-06-15 I am not able to reproduce this on Merlin Build 72. Running RH6.2 richard.ray@eng 2001-07-23
15-06-2001