aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-13 06:35:51 +0100
committerSven Gothel <[email protected]>2012-03-13 06:35:51 +0100
commitbab77b637e7cdd327de5f66989fcbfc0298b9b88 (patch)
tree3659baafc4f0eb84013b14cbd99efa1d7154b759 /src/java/com/jogamp
parent8d5786376337bcd40095c5a4d13e40696021e311 (diff)
Intro.: PropertyAccess ; Added safe PropertyAccess for JNILibLoaderBase, Platform, IOUtil, ..
- Intro.: PropertyAccess - Base class of all Debug impl, reduces redundancies. - jnlpAlias'ed trusted property is queried within local AccessControlContext to avoid 'JRE' implementation differences (should not be required). - throw NPE and IllegalArgumentException for invalid property key - Added safe PropertyAccess - JNILibLoaderBase: sun.jnlp.applet.launcher - Platform: jogamp.gluegen.UseTempJarCache - IOUtil: java.io.tmpdir
Diffstat (limited to 'src/java/com/jogamp')
-rw-r--r--src/java/com/jogamp/common/jvm/JNILibLoaderBase.java5
-rw-r--r--src/java/com/jogamp/common/os/Platform.java8
-rw-r--r--src/java/com/jogamp/common/util/IOUtil.java8
-rw-r--r--src/java/com/jogamp/common/util/locks/Lock.java6
-rw-r--r--src/java/com/jogamp/gluegen/Logging.java12
5 files changed, 22 insertions, 17 deletions
diff --git a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
index fd12b7f..a5c68e7 100644
--- a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
+++ b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
@@ -51,6 +51,7 @@ import com.jogamp.common.util.JarUtil;
import com.jogamp.common.util.cache.TempJarCache;
import jogamp.common.Debug;
+import jogamp.common.PropertyAccess;
public class JNILibLoaderBase {
public static final boolean DEBUG = Debug.debug("JNILibLoader");
@@ -229,8 +230,8 @@ public class JNILibLoaderBase {
static {
final String sunAppletLauncherProperty = "sun.jnlp.applet.launcher";
final String sunAppletLauncherClassName = "org.jdesktop.applet.util.JNLPAppletLauncher";
- final boolean usingJNLPAppletLauncher = Boolean.valueOf(System.getProperty(sunAppletLauncherProperty)).booleanValue();
-
+ final boolean usingJNLPAppletLauncher = PropertyAccess.getBooleanProperty(sunAppletLauncherProperty, true, AccessController.getContext());
+
Class<?> launcherClass = null;
Method loadLibraryMethod = null;
diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java
index 61b7345..ac1a1d0 100644
--- a/src/java/com/jogamp/common/os/Platform.java
+++ b/src/java/com/jogamp/common/os/Platform.java
@@ -41,7 +41,7 @@ import com.jogamp.common.util.JarUtil;
import com.jogamp.common.util.VersionNumber;
import com.jogamp.common.util.cache.TempJarCache;
-import jogamp.common.Debug;
+import jogamp.common.PropertyAccess;
import jogamp.common.jvm.JVMUtil;
import jogamp.common.os.MachineDescriptionRuntime;
@@ -205,11 +205,7 @@ public class Platform {
os_and_arch = getOSAndArch(OS_TYPE, CPU_ARCH);
USE_TEMP_JAR_CACHE = (OS_TYPE != OSType.ANDROID) && isRunningFromJarURL() &&
- AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
- public Boolean run() {
- return Boolean.valueOf(Debug.getBooleanProperty(true, useTempJarCachePropName, true, AccessController.getContext()));
- }
- }).booleanValue();
+ PropertyAccess.getBooleanProperty(useTempJarCachePropName, true, AccessController.getContext(), true);
loadGlueGenRTImpl();
JVMUtil.initSingleton(); // requires gluegen-rt, one-time init.
diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java
index 0463c37..cdbeab6 100644
--- a/src/java/com/jogamp/common/util/IOUtil.java
+++ b/src/java/com/jogamp/common/util/IOUtil.java
@@ -44,6 +44,7 @@ import java.net.URLConnection;
import java.nio.ByteBuffer;
import jogamp.common.Debug;
+import jogamp.common.PropertyAccess;
import jogamp.common.os.android.StaticContext;
import android.content.Context;
@@ -510,11 +511,14 @@ public class IOUtil {
* for both platforms w/o the need to handle extra permissions.
* </p>
*
+ * @throws SecurityException
+ * @throws RuntimeException
+ *
* @see StaticContext#setContext(Context)
* @see Context#getDir(String, int)
*/
public static File getTempRoot()
- throws SecurityException
+ throws SecurityException, RuntimeException
{
if(AndroidVersion.isAvailable) {
final Context ctx = StaticContext.getContext();
@@ -526,7 +530,7 @@ public class IOUtil {
return tmpRoot;
}
}
- final String tmpRootName = System.getProperty("java.io.tmpdir");
+ final String tmpRootName = PropertyAccess.getProperty("java.io.tmpdir", false, AccessController.getContext());
final File tmpRoot = new File(tmpRootName);
if(DEBUG) {
System.err.println("IOUtil.getTempRoot(isAndroid: "+AndroidVersion.isAvailable+"): temp dir: "+tmpRoot.getAbsolutePath());
diff --git a/src/java/com/jogamp/common/util/locks/Lock.java b/src/java/com/jogamp/common/util/locks/Lock.java
index 15d01ec..b2d6acc 100644
--- a/src/java/com/jogamp/common/util/locks/Lock.java
+++ b/src/java/com/jogamp/common/util/locks/Lock.java
@@ -29,6 +29,8 @@
package com.jogamp.common.util.locks;
import jogamp.common.Debug;
+import jogamp.common.PropertyAccess;
+
import java.security.AccessController;
/**
@@ -37,7 +39,7 @@ import java.security.AccessController;
public interface Lock {
/** Enable via the property <code>jogamp.debug.Lock.TraceLock</code> */
- public static final boolean TRACE_LOCK = Debug.isPropertyDefined("jogamp.debug.Lock.TraceLock", true, AccessController.getContext());
+ public static final boolean TRACE_LOCK = PropertyAccess.isPropertyDefined("jogamp.debug.Lock.TraceLock", true, AccessController.getContext());
/** Enable via the property <code>jogamp.debug.Lock</code> */
public static final boolean DEBUG = Debug.debug("Lock");
@@ -50,7 +52,7 @@ public interface Lock {
* and defaults to {@link #DEFAULT_TIMEOUT}.<br>
* It can be overridden via the system property <code>jogamp.common.utils.locks.Lock.timeout</code>.
*/
- public static final long TIMEOUT = Debug.getLongProperty("jogamp.common.utils.locks.Lock.timeout", true, AccessController.getContext(), DEFAULT_TIMEOUT);
+ public static final long TIMEOUT = PropertyAccess.getLongProperty("jogamp.common.utils.locks.Lock.timeout", true, AccessController.getContext(), DEFAULT_TIMEOUT);
/**
* Blocking until the lock is acquired by this Thread or {@link #TIMEOUT} is reached.
diff --git a/src/java/com/jogamp/gluegen/Logging.java b/src/java/com/jogamp/gluegen/Logging.java
index 9ad3bf7..556819e 100644
--- a/src/java/com/jogamp/gluegen/Logging.java
+++ b/src/java/com/jogamp/gluegen/Logging.java
@@ -31,12 +31,15 @@
*/
package com.jogamp.gluegen;
+import java.security.AccessController;
import java.util.logging.ConsoleHandler;
import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
+import jogamp.common.PropertyAccess;
+
/**
*
* @author Michael Bien
@@ -44,9 +47,8 @@ import java.util.logging.Logger;
public class Logging {
static void init() {
-
- String pakage = Logging.class.getPackage().getName();
- String property = System.getProperty(pakage+".level");
+ final String packageName = Logging.class.getPackage().getName();
+ final String property = PropertyAccess.getProperty(packageName+".level", true, AccessController.getContext());
Level level;
if(property != null) {
level = Level.parse(property);
@@ -63,7 +65,7 @@ public class Logging {
handler.setFormatter(new PlainLogFormatter());
handler.setLevel(level);
- Logger rootPackageLogger = Logger.getLogger(pakage);
+ Logger rootPackageLogger = Logger.getLogger(packageName);
rootPackageLogger.setUseParentHandlers(false);
rootPackageLogger.setLevel(level);
rootPackageLogger.addHandler(handler);
@@ -75,7 +77,7 @@ public class Logging {
*/
private static class PlainLogFormatter extends Formatter {
- //@Override
+ @Override
public String format(LogRecord record) {
StringBuilder sb = new StringBuilder(128);
sb.append("[").append(record.getLevel()).append(' ').append(record.getSourceClassName()).append("]: ");