diff options
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/com/jogamp/common/os/Platform.java | 32 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/ReflectionUtil.java | 14 |
2 files changed, 33 insertions, 13 deletions
diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index 0d8b276..2dc4532 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -34,6 +34,8 @@ import com.jogamp.common.nio.Buffers; import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.nio.ShortBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; /** * Utility class for querying platform specific properties. @@ -60,14 +62,14 @@ public class Platform { ARCH = System.getProperty("os.arch"); pointerSizeInBits = getPointerSizeInBitsImpl(); - is32Bit = initAch(); + is32Bit = initArch(); JAVA_SE = initIsJavaSE(); LITTLE_ENDIAN = initByteOrder(); } private Platform() {} - private static boolean initAch() throws RuntimeException { + private static boolean initArch() throws RuntimeException { // Try to use Sun's sun.ARCH.data.model first .. if ( 32 == pointerSizeInBits || 64 == pointerSizeInBits ) { return 32 == pointerSizeInBits; @@ -104,10 +106,14 @@ public class Platform { } private static boolean initIsJavaSE() { + boolean javaSEChecked = false; // fast path for desktop - if(System.getSecurityManager() == null && System.getProperty("java.runtime.name").indexOf("Java SE") != -1) { - return true; + if(System.getSecurityManager() == null) { + javaSEChecked = true; + if(System.getProperty("java.runtime.name").indexOf("Java SE") != -1) { + return true; + } } // probe for classes we need on a SE environment @@ -115,9 +121,23 @@ public class Platform { Class.forName("java.nio.LongBuffer"); Class.forName("java.nio.DoubleBuffer"); return true; - }catch(ClassNotFoundException ex) { - return false; + } catch(ClassNotFoundException ex) { + // continue with Java SE check + } + + if(!javaSEChecked) { + // no more the fast path, due to access controller .. + String java_runtime_name = (String) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty("java.runtime.name"); + } + }); + if(java_runtime_name.indexOf("Java SE") != -1) { + return true; + } } + + return false; } private static boolean initByteOrder() { diff --git a/src/java/com/jogamp/common/util/ReflectionUtil.java b/src/java/com/jogamp/common/util/ReflectionUtil.java index fc4352f..cd4c062 100644 --- a/src/java/com/jogamp/common/util/ReflectionUtil.java +++ b/src/java/com/jogamp/common/util/ReflectionUtil.java @@ -75,7 +75,7 @@ public final class ReflectionUtil { /** * @throws JogampRuntimeException if the constructor can not be delivered. */ - public static final Constructor getConstructor(String clazzName, ClassLoader cl, Class[] cstrArgTypes) + public static final Constructor getConstructor(String clazzName, Class[] cstrArgTypes, ClassLoader cl) throws JogampRuntimeException { try { return getConstructor(getClassImpl(clazzName, true, cl), cstrArgTypes); @@ -111,7 +111,7 @@ public final class ReflectionUtil { public static final Constructor getConstructor(String clazzName, ClassLoader cl) throws JogampRuntimeException { - return getConstructor(clazzName, cl, new Class[0]); + return getConstructor(clazzName, new Class[0], cl); } /** @@ -147,7 +147,7 @@ public final class ReflectionUtil { return createInstance(clazz, cstrArgTypes, cstrArgs); } - public static final Object createInstance(String clazzName, ClassLoader cl, Class[] cstrArgTypes, Object[] cstrArgs) + public static final Object createInstance(String clazzName, Class[] cstrArgTypes, Object[] cstrArgs, ClassLoader cl) throws JogampRuntimeException, RuntimeException { try { @@ -157,20 +157,20 @@ public final class ReflectionUtil { } } - public static final Object createInstance(String clazzName, ClassLoader cl, Object[] cstrArgs) + public static final Object createInstance(String clazzName, Object[] cstrArgs, ClassLoader cl) throws JogampRuntimeException, RuntimeException { Class[] cstrArgTypes = new Class[cstrArgs.length]; for(int i=0; i<cstrArgs.length; i++) { cstrArgTypes[i] = cstrArgs[i].getClass(); } - return createInstance(clazzName, cl, cstrArgTypes, cstrArgs); + return createInstance(clazzName, cstrArgTypes, cstrArgs, cl); } public static final Object createInstance(String clazzName, ClassLoader cl) throws JogampRuntimeException, RuntimeException { - return createInstance(clazzName, cl, new Class[0], null); + return createInstance(clazzName, new Class[0], null, cl); } public static final boolean instanceOf(Object obj, String clazzName) { @@ -214,7 +214,7 @@ public final class ReflectionUtil { /** * @throws JogampRuntimeException if the instance can not be created. */ - public static final Object callStaticMethod(String clazzName, ClassLoader cl, String methodName, Class[] argTypes, Object[] args) + public static final Object callStaticMethod(String clazzName, String methodName, Class[] argTypes, Object[] args, ClassLoader cl) throws JogampRuntimeException, RuntimeException { Class clazz; |