diff options
author | Sven Gothel <[email protected]> | 2009-07-03 23:31:02 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-07-03 23:31:02 +0000 |
commit | 944a0ca587d20d193b9f8c7b5edbd0b0bd0d7666 (patch) | |
tree | 61473a7a57d71427ce8fdf927eefc74130e093bb /src/newt/classes/com/sun/javafx | |
parent | 02ccc7939e2c542860f154e4f9063dbb1839a893 (diff) |
Fix property query. Thx to Ken pointing this out.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@2018 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/newt/classes/com/sun/javafx')
-rwxr-xr-x | src/newt/classes/com/sun/javafx/newt/Screen.java | 6 | ||||
-rw-r--r-- | src/newt/classes/com/sun/javafx/newt/impl/Debug.java | 71 | ||||
-rw-r--r-- | src/newt/classes/com/sun/javafx/newt/util/MainThread.java | 4 |
3 files changed, 60 insertions, 21 deletions
diff --git a/src/newt/classes/com/sun/javafx/newt/Screen.java b/src/newt/classes/com/sun/javafx/newt/Screen.java index 4c184bc99..2566041a8 100755 --- a/src/newt/classes/com/sun/javafx/newt/Screen.java +++ b/src/newt/classes/com/sun/javafx/newt/Screen.java @@ -36,6 +36,7 @@ package com.sun.javafx.newt; import com.sun.javafx.newt.impl.*; import javax.media.nativewindow.*; +import java.security.*; public abstract class Screen { @@ -62,8 +63,8 @@ public abstract class Screen { protected static Screen create(String type, Display display, int idx) { try { if(usrWidth<0 || usrHeight<0) { - usrWidth = Debug.getIntProperty("newt.ws.swidth", true); - usrHeight = Debug.getIntProperty("newt.ws.sheight", true); + usrWidth = Debug.getIntProperty("newt.ws.swidth", true, localACC); + usrHeight = Debug.getIntProperty("newt.ws.sheight", true, localACC); System.out.println("User screen size "+usrWidth+"x"+usrHeight); } Class screenClass = getScreenClass(type); @@ -137,5 +138,6 @@ public abstract class Screen { protected AbstractGraphicsScreen aScreen; protected int width=-1, height=-1; // detected values: set using setScreenSize protected static int usrWidth=-1, usrHeight=-1; // property values: newt.ws.swidth and newt.ws.sheight + private static AccessControlContext localACC = AccessController.getContext(); } diff --git a/src/newt/classes/com/sun/javafx/newt/impl/Debug.java b/src/newt/classes/com/sun/javafx/newt/impl/Debug.java index 57ce88618..ed8531295 100644 --- a/src/newt/classes/com/sun/javafx/newt/impl/Debug.java +++ b/src/newt/classes/com/sun/javafx/newt/impl/Debug.java @@ -47,10 +47,12 @@ public class Debug { // Some common properties private static boolean verbose; private static boolean debugAll; + private static AccessControlContext localACC; static { - verbose = isPropertyDefined("newt.verbose"); - debugAll = isPropertyDefined("newt.debug"); + localACC=AccessController.getContext(); + verbose = isPropertyDefined("newt.verbose", true); + debugAll = isPropertyDefined("newt.debug", true); if (verbose) { Package p = Package.getPackage("com.sun.javafx.newt"); System.err.println("NEWT specification version " + p.getSpecificationVersion()); @@ -59,34 +61,67 @@ public class Debug { } } - public static int getIntProperty(final String property, final boolean jnlpAlias) { + protected static int getIntProperty(final String property, final boolean jnlpAlias) { + return getIntProperty(property, jnlpAlias, localACC); + } + + public static int getIntProperty(final String property, final boolean jnlpAlias, final AccessControlContext acc) { int i=0; try { - Integer iv = Integer.valueOf(Debug.getProperty(property, jnlpAlias)); + Integer iv = Integer.valueOf(Debug.getProperty(property, jnlpAlias, acc)); i = iv.intValue(); } catch (NumberFormatException nfe) {} return i; } - public static boolean getBooleanProperty(final String property, final boolean jnlpAlias) { - Boolean b = Boolean.valueOf(Debug.getProperty(property, jnlpAlias)); + protected static boolean getBooleanProperty(final String property, final boolean jnlpAlias) { + return getBooleanProperty(property, jnlpAlias, localACC); + } + + public static boolean getBooleanProperty(final String property, final boolean jnlpAlias, final AccessControlContext acc) { + Boolean b = Boolean.valueOf(Debug.getProperty(property, jnlpAlias, acc)); return b.booleanValue(); } - public static boolean isPropertyDefined(final String property) { - return (Debug.getProperty(property, true) != null) ? true : false; + protected static boolean isPropertyDefined(final String property, final boolean jnlpAlias) { + return isPropertyDefined(property, jnlpAlias, localACC); } - public static String getProperty(final String property, final boolean jnlpAlias) { - String s = (String) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - String val = System.getProperty(property); - if(null==val && jnlpAlias && !property.startsWith(jnlp_prefix)) { - val = System.getProperty(jnlp_prefix + property); - } - return val; + public static boolean isPropertyDefined(final String property, final boolean jnlpAlias, final AccessControlContext acc) { + return (Debug.getProperty(property, jnlpAlias, acc) != null) ? true : false; + } + + protected static String getProperty(final String property, final boolean jnlpAlias) { + return getProperty(property, jnlpAlias, localACC); + } + + public static String getProperty(final String property, final boolean jnlpAlias, final AccessControlContext acc) { + String s=null; + if(null!=acc && acc.equals(localACC)) { + s = (String) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + String val=null; + try { + val = System.getProperty(property); + } catch (Exception e) {} + if(null==val && jnlpAlias && !property.startsWith(jnlp_prefix)) { + try { + val = System.getProperty(jnlp_prefix + property); + } catch (Exception e) {} + } + return val; + } + }); + } else { + try { + s = System.getProperty(property); + } catch (Exception e) {} + if(null==s && jnlpAlias && !property.startsWith(jnlp_prefix)) { + try { + s = System.getProperty(jnlp_prefix + property); + } catch (Exception e) {} } - }); + } return s; } public static final String jnlp_prefix = "jnlp." ; @@ -100,6 +135,6 @@ public class Debug { } public static boolean debug(String subcomponent) { - return debugAll() || isPropertyDefined("newt.debug." + subcomponent); + return debugAll() || isPropertyDefined("newt.debug." + subcomponent, true); } } diff --git a/src/newt/classes/com/sun/javafx/newt/util/MainThread.java b/src/newt/classes/com/sun/javafx/newt/util/MainThread.java index 3230f504b..abfe3f0c7 100644 --- a/src/newt/classes/com/sun/javafx/newt/util/MainThread.java +++ b/src/newt/classes/com/sun/javafx/newt/util/MainThread.java @@ -39,6 +39,7 @@ package com.sun.javafx.newt.util; import java.util.*; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; +import java.security.*; import javax.media.nativewindow.*; @@ -81,8 +82,9 @@ import com.sun.nativewindow.impl.NWReflection; * Which starts 4 threads, each with a window and OpenGL rendering.<br> */ public class MainThread { + private static AccessControlContext localACC = AccessController.getContext(); public static final boolean USE_MAIN_THREAD = NativeWindowFactory.TYPE_MACOSX.equals(NativeWindowFactory.getNativeWindowType(false)) || - Debug.getBooleanProperty("newt.MainThread.force", true); + Debug.getBooleanProperty("newt.MainThread.force", true, localACC); protected static final boolean DEBUG = Debug.debug("MainThread"); |