src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java
Print this page
*** 26,35 ****
--- 26,36 ----
package java.awt;
import java.awt.image.BufferedImage;
import java.security.AccessController;
+ import java.security.PrivilegedAction;
import java.util.Locale;
import sun.font.FontManager;
import sun.font.FontManagerFactory;
import sun.java2d.HeadlessGraphicsEnvironment;
*** 159,171 ****
* @return the value of the property "java.awt.headless"
* @since 1.4
*/
private static boolean getHeadlessProperty() {
if (headless == null) {
! java.security.AccessController.doPrivileged(
! new java.security.PrivilegedAction<Object>() {
! public Object run() {
String nm = System.getProperty("java.awt.headless");
if (nm == null) {
/* No need to ask for DISPLAY when run in a browser */
if (System.getProperty("javaplugin.version") != null) {
--- 160,170 ----
* @return the value of the property "java.awt.headless"
* @since 1.4
*/
private static boolean getHeadlessProperty() {
if (headless == null) {
! AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
String nm = System.getProperty("java.awt.headless");
if (nm == null) {
/* No need to ask for DISPLAY when run in a browser */
if (System.getProperty("javaplugin.version") != null) {
*** 175,205 ****
if (osName.contains("OS X") && "sun.awt.HToolkit".equals(
System.getProperty("awt.toolkit")))
{
headless = defaultHeadless = Boolean.TRUE;
} else {
headless = defaultHeadless =
! Boolean.valueOf(("Linux".equals(osName) ||
"SunOS".equals(osName) ||
"FreeBSD".equals(osName) ||
"NetBSD".equals(osName) ||
"OpenBSD".equals(osName) ||
"AIX".equals(osName)) &&
! (System.getenv("DISPLAY") == null));
}
}
- } else if (nm.equals("true")) {
- headless = Boolean.TRUE;
} else {
! headless = Boolean.FALSE;
}
return null;
}
! }
! );
! }
! return headless.booleanValue();
}
/**
* Check for headless state and throw HeadlessException if headless
* @since 1.4
--- 174,201 ----
if (osName.contains("OS X") && "sun.awt.HToolkit".equals(
System.getProperty("awt.toolkit")))
{
headless = defaultHeadless = Boolean.TRUE;
} else {
+ final String display = System.getenv("DISPLAY");
headless = defaultHeadless =
! ("Linux".equals(osName) ||
"SunOS".equals(osName) ||
"FreeBSD".equals(osName) ||
"NetBSD".equals(osName) ||
"OpenBSD".equals(osName) ||
"AIX".equals(osName)) &&
! (display == null || display.isEmpty());
}
}
} else {
! headless = "true".equals(nm);
}
return null;
+ });
}
! return headless;
}
/**
* Check for headless state and throw HeadlessException if headless
* @since 1.4