test/demo/jvmti/mtrace/JFrameCreateTime.java
Print this page
@@ -30,14 +30,34 @@
/* Early in 1.5 it was reported that doing a step into the first JFrame
* was very slow (VisualMust debugger people reported this).
*/
-import javax.swing.*;
+import java.awt.GraphicsEnvironment;
+import javax.swing.JFrame;
public class JFrameCreateTime {
public static void main(String[] args) {
+ boolean isHeadless = true;
+ try {
+ //AWT has a problem on Mac OS with defined DISPLAY variable.
+ //For the case the X11 toolkit is been loading in ssh test session,
+ //but Mac OS implementation of X11 toolkit has a deadlock/linkage problem.
+ //In JDK8 the X11 toolkit support is obsolete and problem would
+ //be resolved by AWT team.
+ isHeadless = (
+ System.getProperty("os.name").contains("OS X")
+ && System.getenv("DISPLAY") != null
+ ) || GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance();
+ } catch (Throwable e) {
+ System.out.println("Test has a problem with AWT initialization in the headless mode: "
+ + e);
+ }
+
+ if (isHeadless) {
+ System.out.println("JFrame test was skipped due to headless mode");
+ } else {
JFrame f;
long start, end;
start = System.currentTimeMillis();
f = new JFrame("JFrame");
@@ -46,10 +66,10 @@
System.out.println("JFrame first creation took " + (end - start) + " ms");
start = System.currentTimeMillis();
f = new JFrame("JFrame");
end = System.currentTimeMillis();
-
System.out.println("JFrame second creation took " + (end - start) + " ms");
+ }
System.exit(0);
}
}