JDK-6329226 : Trying to construct two java.awt.Robot instances hangs over Exceed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P5
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: linux
  • CPU: x86
  • Submitted: 2005-09-27
  • Updated: 2011-02-16
  • Resolved: 2006-02-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
1.5.0_04 

ADDITIONAL OS VERSION INFORMATION :
Linux 2.4.18 #18 SMP i686 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
This bug does not exist with version 1.4.1 (did not try 1.4.2).  With 1.5, trying to create a Robot object after the 1st creation has failed causes the application to hang.  We see this when using Exceed (Hummingbird) to run on Linux from Windows XP.  The Robot API is not supported in this configuration--

java.awt.AWTException: java.awt.Robot requires your X server support the XTEST extension version 2.2.

This is fine as our code is robust to the case where a Robot instance cannot be created.

However, if we then try AGAIN to create another Robot object during the same VM session, the application hangs.  This is true even if the attempts do not immediately follow each other.  It appears that a lock is not being released.

The problem exists with 1.5.0_04 as well.  Please do investigate
this issue.  Note that the problem is not reproducible with Exceed if
XTEST(X11R6) is enabled via Exceed's xconfig, X Server Protocol,
Extensions tab.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
With the 1.5 VM run RobotExceedHang

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When doing with 1.4, you get the following (correct):

[ahrensclinux:/sandbox/cahrens/splitscreen]165 % java  RobotExceedHang
XTEST extension not installed on this X server: Success
java.awt.AWTException: java.awt.Robot requires your X server support the XTEST extension version 2.2
        at sun.awt.motif.MRobotPeer.setup(Native Method)
        at sun.awt.motif.MRobotPeer.<init>(MRobotPeer.java:41)
        at sun.awt.motif.MToolkit.createRobot(MToolkit.java:571)
        at java.awt.Robot.init(Robot.java:115)
        at java.awt.Robot.<init>(Robot.java:74)
        at RobotExceedHang.runTest(RobotExceedHang.java:7)
        at RobotExceedHang.main(RobotExceedHang.java:22)
TRY AGAIN TO CREATE ROBOT
XTEST extension not installed on this X server: Success
java.awt.AWTException: java.awt.Robot requires your X server support the XTEST extension version 2.2
        at sun.awt.motif.MRobotPeer.setup(Native Method)
        at sun.awt.motif.MRobotPeer.<init>(MRobotPeer.java:41)
        at sun.awt.motif.MToolkit.createRobot(MToolkit.java:571)
        at java.awt.Robot.init(Robot.java:115)
        at java.awt.Robot.<init>(Robot.java:74)
        at RobotExceedHang.runTest(RobotExceedHang.java:14)
        at RobotExceedHang.main(RobotExceedHang.java:22)


ACTUAL -
With 1.5 the application hangs when attempting to create the second Robot instance:

[ahrensclinux:/sandbox/cahrens/splitscreen]164 % /hub/Linux/glibc-2.2.5/i686/apps/java/jre1.5.0/bin/java RobotExceedHang
XTEST extension not installed on this X server: Success
java.awt.AWTException: java.awt.Robot requires your X server support the XTEST extension version 2.2
        at sun.awt.X11.XRobotPeer.setup(Native Method)
        at sun.awt.X11.XRobotPeer.<init>(Unknown Source)
        at sun.awt.X11.XToolkit.createRobot(Unknown Source)
        at java.awt.Robot.init(Unknown Source)
        at java.awt.Robot.<init>(Unknown Source)
        at RobotExceedHang.runTest(RobotExceedHang.java:7)
        at RobotExceedHang.main(RobotExceedHang.java:22)
TRY AGAIN TO CREATE ROBOT




ERROR MESSAGES/STACK TRACES THAT OCCUR :
When killing our application in this state, this is the thread that is hung:

"AWT-EventQueue-0" prio=1 tid=0x087b6238 nid=0x1ae4 runnable [0xbddfe000..0xbddff50c]
at sun.awt.motif.MRobotPeer.setup(Native Method)
- locked <0x6bef7208> (a java.lang.Class)
at sun.awt.motif.MRobotPeer.<init>(Unknown Source)
at sun.awt.motif.MToolkit.createRobot(Unknown Source)
at java.awt.Robot.init(Unknown Source)
at java.awt.Robot.<init>(Unknown Source)
at com.mathworks.widgets.SyntaxTextPaneMultiView$DragButton.<init>(SyntaxTextPaneMultiView.java:1321)
at com.mathworks.widgets.SyntaxTextPaneMultiView$DragButton.<init>(SyntaxTextPaneMultiView.java:1291)
at com.mathworks.widgets.SyntaxTextPaneMultiView.populatePanel(SyntaxTextPaneMultiView.java:272)
at com.mathworks.widgets.SyntaxTextPaneMultiView.splitScreen(SyntaxTextPaneMultiView.java:201)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;

public class RobotExceedHang {

    public static void runTest() {
        try {
            new Robot();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("TRY AGAIN TO CREATE ROBOT");
        try {
            new Robot();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        runTest();
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Must keep around global state about whether or not the 1st attempt to create a Robot object failed.