-
Bug
-
Resolution: Won't Fix
-
P5
-
None
-
1.3.0
-
x86
-
windows_98
Name: boT120536 Date: 04/29/2001
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)
The InterruptedException exception generated inside the java.awt.Robot class's
delay(...) method can not be handled by the calling application. The bug can be
found in the Java 2 SDK 1.3.1 RC1 on Windows NT 4.0, too. Here is the sample
code, which clearly demonstrates the bug:
/*
* This code demonstrates the bug in the java.awt.Robot class related to the
* delay(...) method. An interruption of the thread, waiting for the expiration
* of the time period specified as an argument to the delay(...) method, could
* cause an abrupt exit from the application. The exception generated inside
* the Robot's delay(...) method can not be handled!
*/
import java.awt.*;
public class RobotTest {
static Robot robot;
static class DormantThread extends Thread {
public void run() {
try {
// This call should behave exactly as Thread.sleep(5000), but
// due to the bug in the Robot class, it does not.
robot.delay(5000);
} catch (Throwable ignored) {}
}
}
public static void main(String args[]) {
Thread t = new DormantThread();
try {
robot = new Robot();
} catch (AWTException e) {
System.exit(1);
}
t.start();
try {
Thread.sleep(1000);
} catch (InterruptedException ingored) {}
t.interrupt();
System.exit(0);
}
}
After running the program listed above, the following error message is shown in
the command window:
java.lang.InterruptedException: sleep interrupted
at java.lang.Thread.sleep(Native Method)
at java.awt.Robot.delay(Robot.java:356)
at RobotTest$DormantThread.run(RobotTest.java:19)
By analyzing the sample code, it is obvious, that this message should never
appear in the command window.
(Review ID: 121165)
======================================================================
- relates to
-
JDK-8210231 Robot.delay() catches InterruptedException and prints stacktrace to stderr
-
- Resolved
-