8024626: CTW CRASH: SIGSEGV in ctw/jre/lib/rt_jar/preloading_1 and ctw/jre/lib/rt_jar/sun_awt_X11_ListHelper
authorserb
Wed, 03 Dec 2014 18:04:50 +0300
changeset 28084 441853c190f4
parent 28083 91a04df877cc
child 28085 9e63471010ac
8024626: CTW CRASH: SIGSEGV in ctw/jre/lib/rt_jar/preloading_1 and ctw/jre/lib/rt_jar/sun_awt_X11_ListHelper Reviewed-by: azvegint, alexsch
jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java	Wed Dec 03 15:43:25 2014 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java	Wed Dec 03 18:04:50 2014 +0300
@@ -103,11 +103,11 @@
     static TreeMap<Long, XBaseWindow> winMap = new TreeMap<>();
     static HashMap<Object, Object> specialPeerMap = new HashMap<>();
     static HashMap<Long, Collection<XEventDispatcher>> winToDispatcher = new HashMap<>();
-    private static long _display;
     static UIDefaults uidefaults;
-    static X11GraphicsEnvironment localEnv;
-    static X11GraphicsDevice device;
-    static final X11GraphicsConfig config;
+    static final X11GraphicsEnvironment localEnv;
+    private static final X11GraphicsDevice device;
+    private static final X11GraphicsConfig config;
+    private static final long display;
     static int awt_multiclick_time;
     static boolean securityWarningEnabled;
 
@@ -118,15 +118,16 @@
     static {
         initSecurityWarning();
         if (GraphicsEnvironment.isHeadless()) {
+            localEnv = null;
+            device = null;
             config = null;
+            display = 0;
         } else {
             localEnv = (X11GraphicsEnvironment) GraphicsEnvironment
                 .getLocalGraphicsEnvironment();
             device = (X11GraphicsDevice) localEnv.getDefaultScreenDevice();
-            config = (X11GraphicsConfig) (device.getDefaultConfiguration());
-            if (device != null) {
-                _display = device.getDisplay();
-            }
+            config = (X11GraphicsConfig) device.getDefaultConfiguration();
+            display = device.getDisplay();
             setupModifierMap();
             initIDs();
             setBackingStoreType();
@@ -197,10 +198,18 @@
         }
     }
 
-    static Object displayLock = new Object();
-
+    /**
+     * Returns the X11 Display of the default screen device.
+     *
+     * @return X11 Display
+     * @throws AWTError thrown if local GraphicsEnvironment is null, which
+     *         means we are in the headless environment
+     */
     public static long getDisplay() {
-        return _display;
+        if (localEnv == null) {
+            throw new AWTError("Local GraphicsEnvironment must not be null");
+        }
+        return display;
     }
 
     public static long getDefaultRootWindow() {