harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apavle...@apache.org
Subject svn commit: r635734 - /harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java
Date Mon, 10 Mar 2008 22:32:15 GMT
Author: apavlenko
Date: Mon Mar 10 15:32:05 2008
New Revision: 635734

URL: http://svn.apache.org/viewvc?rev=635734&view=rev
Log:
The property java.awt.headless should be read in a privileged mode

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java?rev=635734&r1=635733&r2=635734&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java
Mon Mar 10 15:32:05 2008
@@ -22,6 +22,8 @@
 package java.awt;
 
 import java.awt.image.BufferedImage;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Locale;
 
 import org.apache.harmony.awt.ContextStorage;
@@ -29,6 +31,9 @@
 
 
 public abstract class GraphicsEnvironment {
+
+    static Boolean isHeadless;
+
     protected GraphicsEnvironment() {}
 
     public static GraphicsEnvironment getLocalGraphicsEnvironment() {
@@ -55,7 +60,15 @@
     }
 
     public static boolean isHeadless() {
-        return "true".equals(System.getProperty("java.awt.headless"));
+        if (isHeadless == null) {
+            isHeadless = AccessController.doPrivileged(new PrivilegedAction<Boolean>()
{
+                public Boolean run() {
+                    return "true".equals(System.getProperty("java.awt.headless")); //$NON-NLS-1$
//$NON-NLS-2$
+                }
+            });
+        }
+        
+        return isHeadless.booleanValue();
     }
 
     public Rectangle getMaximumWindowBounds() throws HeadlessException {



Mime
View raw message