Hi all,

When I ran HSDB by jhsdb on CLI i.e. without x11 display, HSDB could
not terminate after throwing HeadlessException.

HSDB starts WorkerThread before making the JFrame. If we run HSDB on
CLI, HSDB throws HeadlessException when makes the JFrame. Thus, the
WorkerThread has never shutdown, then HSDB can not terminate.

-----
Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an
operation which requires it.
        at 
java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:205)
        at java.awt.Window.<init>(Window.java:535)
        at java.awt.Frame.<init>(Frame.java:422)
        at javax.swing.JFrame.<init>(JFrame.java:224)
        at sun.jvm.hotspot.HSDB.run(HSDB.java:140)
        at sun.jvm.hotspot.HSDB.main(HSDB.java:53)
        at sun.jvm.hotspot.SALauncher.runHSDB(SALauncher.java:167)
        at sun.jvm.hotspot.SALauncher.main(SALauncher.java:339)
## Waiting for the shutdown of WorkerThread forever... ###
-----

I have created a patch from jdk9/dev/hotspot (changeset:
9625:de592ea5f7ba) as below. Please review it !

diff --git a/agent/src/share/classes/sun/jvm/hotspot/HSDB.java
b/agent/src/share/classes/sun/jvm/hotspot/HSDB.java
--- a/agent/src/share/classes/sun/jvm/hotspot/HSDB.java
+++ b/agent/src/share/classes/sun/jvm/hotspot/HSDB.java
@@ -137,15 +137,16 @@
         return;
     }

+    // Make frame at first, then initialize agent.
+    frame = new JFrame("HSDB - HotSpot Debugger");
+    frame.setSize(800, 600);
+    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+
     agent = new HotSpotAgent();
     workerThread = new WorkerThread();
     attachMenuItems = new java.util.ArrayList();
     detachMenuItems = new java.util.ArrayList();

-    frame = new JFrame("HSDB - HotSpot Debugger");
-    frame.setSize(800, 600);
-    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
-
     JMenuBar menuBar = new JMenuBar();

     //


Thanks,
Yuji

Reply via email to