From 7d7e7c901d8fe54af1230cbf10e568f1a8433cbe Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 13 Mar 2012 20:19:19 +0100 Subject: Adapt to gluegen Properties/Security commits f4ac27e177f6deb444280d3b375e7d343e38bd080 and eedb4b530fb83fc59a26962bcf7847a1404092a0 --- .../classes/com/jogamp/graph/font/FontFactory.java | 8 +-- .../com/jogamp/opengl/util/awt/TextRenderer.java | 8 +-- .../com/jogamp/opengl/util/glsl/ShaderCode.java | 3 +- .../com/jogamp/opengl/util/glsl/ShaderState.java | 3 +- .../com/jogamp/opengl/util/texture/Texture.java | 9 ++- .../media/opengl/DefaultGLCapabilitiesChooser.java | 7 +- .../classes/javax/media/opengl/GLAutoDrawable.java | 3 +- src/jogl/classes/javax/media/opengl/GLContext.java | 15 +--- .../javax/media/opengl/GLDrawableFactory.java | 5 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 10 +-- .../font/typecast/TypecastFontConstructor.java | 2 +- src/jogl/classes/jogamp/opengl/Debug.java | 82 ++++----------------- src/jogl/classes/jogamp/opengl/ThreadingImpl.java | 15 ++-- .../classes/jogamp/opengl/windows/wgl/WGLUtil.java | 4 +- .../opengl/windows/wgl/WindowsWGLDrawable.java | 4 +- .../nativewindow/DefaultCapabilitiesChooser.java | 3 +- .../media/nativewindow/NativeWindowFactory.java | 6 +- .../javax/media/nativewindow/ToolkitLock.java | 3 +- .../classes/jogamp/nativewindow/Debug.java | 83 ++++------------------ .../classes/jogamp/nativewindow/x11/X11Util.java | 3 +- .../classes/com/jogamp/newt/util/MainThread.java | 5 +- src/newt/classes/jogamp/newt/Debug.java | 82 ++++----------------- src/newt/classes/jogamp/newt/ScreenImpl.java | 7 +- 23 files changed, 89 insertions(+), 281 deletions(-) diff --git a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java index dff89033c..586bdd919 100644 --- a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java +++ b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java @@ -30,14 +30,14 @@ package com.jogamp.graph.font; import java.io.File; import java.io.IOException; import java.net.URL; -import java.security.AccessController; +import com.jogamp.common.util.PropertyAccess; import com.jogamp.common.util.ReflectionUtil; +import com.jogamp.common.util.SecurityUtil; import jogamp.graph.font.FontConstructor; import jogamp.graph.font.JavaFontLoader; import jogamp.graph.font.UbuntuFontLoader; -import jogamp.opengl.Debug; public class FontFactory { /** Ubuntu is the default font family */ @@ -53,8 +53,8 @@ public class FontFactory { * For example: * "jogamp.graph.font.typecast.TypecastFontFactory" (default) * "jogamp.graph.font.ttf.TTFFontImpl" - */ - String fontImplName = Debug.getProperty("FontImpl", true, AccessController.getContext()); + */ + String fontImplName = PropertyAccess.getProperty("FontImpl", true, SecurityUtil.getCommonAccessControlContext(FontFactory.class)); if(null == fontImplName) { fontImplName = "jogamp.graph.font.typecast.TypecastFontConstructor"; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java index de28dc70a..4318e1244 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java @@ -40,7 +40,7 @@ package com.jogamp.opengl.util.awt; import com.jogamp.common.nio.Buffers; -import jogamp.opengl.Debug; + import com.jogamp.opengl.util.*; import com.jogamp.opengl.util.packrect.*; import com.jogamp.opengl.util.texture.*; @@ -66,12 +66,12 @@ import java.text.*; import java.util.*; -import java.security.*; - import javax.media.opengl.*; import javax.media.opengl.glu.*; import javax.media.opengl.awt.*; +import jogamp.opengl.Debug; + /** Renders bitmapped Java 2D text into an OpenGL window with high performance, full Unicode support, and a simple API. Performs @@ -127,7 +127,7 @@ import javax.media.opengl.awt.*; @author Kenneth Russell */ public class TextRenderer { - private static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.TextRenderer", true, AccessController.getContext()); + private static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.TextRenderer", true); // These are occasionally useful for more in-depth debugging private static final boolean DISABLE_GLYPH_CACHE = false; diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index eec055ed4..8a1c8d313 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -38,11 +38,10 @@ import java.util.*; import java.nio.*; import java.io.*; import java.net.*; -import java.security.*; public class ShaderCode { public static final boolean DEBUG = Debug.debug("GLSLCode"); - public static final boolean DEBUG_CODE = Debug.isPropertyDefined("jogl.debug.GLSLCode", true, AccessController.getContext()); + public static final boolean DEBUG_CODE = Debug.isPropertyDefined("jogl.debug.GLSLCode", true); public static final String SUFFIX_VERTEX_SOURCE = "vp" ; public static final String SUFFIX_VERTEX_BINARY = "bvp" ; diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java index 245f5fb06..3fffae801 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java @@ -28,7 +28,6 @@ package com.jogamp.opengl.util.glsl; -import java.security.AccessController; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -47,7 +46,7 @@ import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.opengl.util.GLArrayDataEditable; public class ShaderState { - public static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLSLState", true, AccessController.getContext()); + public static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLSLState", true); private static final String currentStateKey = "jogamp.opengl.glsl.ShaderState" ; public ShaderState() { diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java index 7f3aa8a39..511b857af 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java @@ -37,12 +37,13 @@ package com.jogamp.opengl.util.texture; import java.nio.*; -import java.security.*; import javax.media.opengl.*; import javax.media.opengl.glu.*; import javax.media.nativewindow.NativeWindowFactory; + import jogamp.opengl.*; + import com.jogamp.opengl.util.texture.spi.*; /** @@ -168,14 +169,12 @@ public class Texture { /** An estimate of the amount of texture memory this texture consumes. */ private int estimatedMemorySize; - private static final AccessControlContext localACC = AccessController.getContext(); - private static final boolean DEBUG = Debug.debug("Texture"); private static final boolean VERBOSE = Debug.verbose(); // For testing alternate code paths on more capable hardware - private static final boolean disableNPOT = Debug.isPropertyDefined("jogl.texture.nonpot", true, localACC); - private static final boolean disableTexRect = Debug.isPropertyDefined("jogl.texture.notexrect", true, localACC); + private static final boolean disableNPOT = Debug.isPropertyDefined("jogl.texture.nonpot", true); + private static final boolean disableTexRect = Debug.isPropertyDefined("jogl.texture.notexrect", true); public Texture(GL gl, TextureData data) throws GLException { texID = 0; diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java index 8aa6d5165..f678c709e 100644 --- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java +++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java @@ -41,12 +41,11 @@ package javax.media.opengl; import javax.media.nativewindow.NativeWindowException; -import jogamp.opengl.Debug; - -import java.security.AccessController; import java.util.List; import javax.media.nativewindow.CapabilitiesImmutable; +import jogamp.opengl.Debug; + /**

The default implementation of the {@link GLCapabilitiesChooser} interface, which provides consistent visual selection behavior across platforms. The precise algorithm is @@ -86,7 +85,7 @@ import javax.media.nativewindow.CapabilitiesImmutable; */ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { - private static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.CapabilitiesChooser", true, AccessController.getContext()); + private static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.CapabilitiesChooser", true); final static int NO_SCORE = -9999999; final static int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000; diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index 9484f0656..c427a9804 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -41,7 +41,6 @@ package javax.media.opengl; import jogamp.opengl.Debug; -import java.security.*; /** A higher-level abstraction than {@link GLDrawable} which supplies an event based mechanism ({@link GLEventListener}) for performing @@ -113,7 +112,7 @@ public interface GLAutoDrawable extends GLDrawable { /** Flag reflecting wheather the drawable reconfiguration will be issued in * case a screen device change occured, e.g. in a multihead environment, * where you drag the window to another monitor. */ - public static final boolean SCREEN_CHANGE_ACTION_ENABLED = Debug.getBooleanProperty("jogl.screenchange.action", true, AccessController.getContext()); + public static final boolean SCREEN_CHANGE_ACTION_ENABLED = Debug.getBooleanProperty("jogl.screenchange.action", true); /** * Returns the context associated with this drawable. The returned diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index cc6b40f54..f928bc126 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -41,8 +41,6 @@ package javax.media.opengl; import java.nio.IntBuffer; -import java.security.AccessControlContext; -import java.security.AccessController; import java.util.HashMap; import java.util.HashSet; @@ -70,18 +68,11 @@ import jogamp.opengl.GLContextImpl; public abstract class GLContext { public static final boolean DEBUG = Debug.debug("GLContext"); - public static final boolean TRACE_SWITCH; + public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true); /** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */ - public final static boolean DEBUG_GL; + public final static boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true); /** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */ - public final static boolean TRACE_GL; - - static { - final AccessControlContext acl = AccessController.getContext(); - DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true, acl); - TRACE_GL = Debug.isPropertyDefined("jogl.debug.TraceGL", true, acl); - TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true, acl); - } + public final static boolean TRACE_GL = Debug.isPropertyDefined("jogl.debug.TraceGL", true); /** Indicates that the context was not made current during the last call to {@link #makeCurrent makeCurrent}. */ public static final int CONTEXT_NOT_CURRENT = 0; diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 26abc53ba..1093685d6 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -46,7 +46,6 @@ import java.util.ArrayList; import java.util.List; import com.jogamp.common.JogampRuntimeException; -import jogamp.common.Debug; import com.jogamp.common.util.ReflectionUtil; @@ -56,6 +55,8 @@ import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; import javax.media.opengl.GLProfile.ShutdownType; +import jogamp.opengl.Debug; + /**

Provides a virtual machine- and operating system-independent mechanism for creating {@link GLDrawable}s.

@@ -122,7 +123,7 @@ public abstract class GLDrawableFactory { final String nativeOSType = NativeWindowFactory.getNativeWindowType(true); GLDrawableFactory tmp = null; - String factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true, AccessController.getContext()); + String factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true); ClassLoader cl = GLDrawableFactory.class.getClassLoader(); if (null == factoryClassName) { if ( nativeOSType.equals(NativeWindowFactory.TYPE_X11) ) { diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 85ffae63e..b30525c95 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -43,8 +43,6 @@ package javax.media.opengl.awt; import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.beans.Beans; -import java.security.AccessControlContext; -import java.security.AccessController; import java.awt.Color; import java.awt.EventQueue; @@ -154,22 +152,20 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // Used by all backends either directly or indirectly to hook up callbacks private Updater updater = new Updater(); - private static final AccessControlContext localACC = AccessController.getContext(); - // Turns off the pbuffer-based backend (used by default, unless the // Java 2D / OpenGL pipeline is in use) private static boolean hardwareAccelerationDisabled = - Debug.isPropertyDefined("jogl.gljpanel.nohw", true, localACC); + Debug.isPropertyDefined("jogl.gljpanel.nohw", true); // Turns off the fallback to software-based rendering from // pbuffer-based rendering private static boolean softwareRenderingDisabled = - Debug.isPropertyDefined("jogl.gljpanel.nosw", true, localACC); + Debug.isPropertyDefined("jogl.gljpanel.nosw", true); // Indicates whether the Java 2D OpenGL pipeline is enabled private boolean oglPipelineEnabled = Java2D.isOGLPipelineActive() && - !Debug.isPropertyDefined("jogl.gljpanel.noogl", true, localACC); + !Debug.isPropertyDefined("jogl.gljpanel.noogl", true); // For handling reshape events lazily // private int reshapeX; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java index 49e8a5826..d5fd34cf7 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java @@ -71,7 +71,7 @@ public class TypecastFontConstructor implements FontConstructor { int len=0; Font f = null; try { - tf = IOUtil.createTempFile( "joglfont", ".ttf"); + tf = IOUtil.createTempFile( "joglfont", ".ttf", null); len = IOUtil.copyURL2File(furl, tf); if(len==0) { tf.delete(); diff --git a/src/jogl/classes/jogamp/opengl/Debug.java b/src/jogl/classes/jogamp/opengl/Debug.java index 83c79c1d3..4287c1960 100644 --- a/src/jogl/classes/jogamp/opengl/Debug.java +++ b/src/jogl/classes/jogamp/opengl/Debug.java @@ -39,18 +39,17 @@ package jogamp.opengl; -import java.security.*; +import com.jogamp.common.util.PropertyAccess; /** Helper routines for logging and debugging. */ -public class Debug { +public class Debug extends PropertyAccess { // Some common properties - private static boolean verbose; - private static boolean debugAll; - private static AccessControlContext localACC; + private static final boolean verbose; + private static final boolean debugAll; static { - localACC=AccessController.getContext(); + PropertyAccess.addTrustedPrefix("jogl.", Debug.class); verbose = isPropertyDefined("jogl.verbose", true); debugAll = isPropertyDefined("jogl.debug", true); if (verbose) { @@ -61,71 +60,18 @@ public class Debug { } } - static int getIntProperty(final String property, final boolean jnlpAlias) { - return getIntProperty(property, jnlpAlias, localACC); + public static final boolean isPropertyDefined(final String property, final boolean jnlpAlias) { + return PropertyAccess.isPropertyDefined(property, jnlpAlias, null); } - - 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, acc)); - i = iv.intValue(); - } catch (NumberFormatException nfe) {} - return i; - } - - 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(); - } - - static boolean isPropertyDefined(final String property, final boolean jnlpAlias) { - return isPropertyDefined(property, jnlpAlias, localACC); - } - - public static boolean isPropertyDefined(final String property, final boolean jnlpAlias, final AccessControlContext acc) { - return (Debug.getProperty(property, jnlpAlias, acc) != null) ? true : false; - } - - static String getProperty(final String property, final boolean jnlpAlias) { - return getProperty(property, jnlpAlias, localACC); + + public static String getProperty(final String property, final boolean jnlpAlias) { + return PropertyAccess.getProperty(property, jnlpAlias, null); } - - 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 boolean getBooleanProperty(final String property, final boolean jnlpAlias) { + return PropertyAccess.getBooleanProperty(property, jnlpAlias, null); } - public static final String jnlp_prefix = "jnlp." ; - + public static boolean verbose() { return verbose; } diff --git a/src/jogl/classes/jogamp/opengl/ThreadingImpl.java b/src/jogl/classes/jogamp/opengl/ThreadingImpl.java index 67a950185..07d5c3402 100644 --- a/src/jogl/classes/jogamp/opengl/ThreadingImpl.java +++ b/src/jogl/classes/jogamp/opengl/ThreadingImpl.java @@ -62,9 +62,9 @@ public class ThreadingImpl { private static final ThreadingPlugin threadingPlugin; static { - Object threadingPluginTmp = - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + threadingPlugin = + AccessController.doPrivileged(new PrivilegedAction() { + public ThreadingPlugin run() { String workaround = Debug.getProperty("jogl.1thread", true); ClassLoader cl = ThreadingImpl.class.getClassLoader(); // Default to using the AWT thread on all platforms except @@ -100,21 +100,20 @@ public class ThreadingImpl { } printWorkaroundNotice(); - Object threadingPluginObj=null; + ThreadingPlugin threadingPlugin=null; if(hasAWT) { // try to fetch the AWTThreadingPlugin Exception error=null; try { - threadingPluginObj = ReflectionUtil.createInstance("jogamp.opengl.awt.AWTThreadingPlugin", cl); + threadingPlugin = (ThreadingPlugin) ReflectionUtil.createInstance("jogamp.opengl.awt.AWTThreadingPlugin", cl); } catch (JogampRuntimeException jre) { error = jre; } - if(AWT == mode && null==threadingPluginObj) { + if(AWT == mode && null==threadingPlugin) { throw new GLException("Mode is AWT, but class 'jogamp.opengl.awt.AWTThreadingPlugin' is not available", error); } } - return threadingPluginObj; + return threadingPlugin; } }); - threadingPlugin = (ThreadingPlugin) threadingPluginTmp; if(DEBUG) { System.err.println("Threading: hasAWT "+hasAWT+", mode "+((mode==AWT)?"AWT":"WORKER")+", plugin "+threadingPlugin); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java index 5c8d38c05..f1598d580 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java @@ -27,8 +27,6 @@ */ package jogamp.opengl.windows.wgl; -import java.security.AccessController; - import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR; import jogamp.opengl.Debug; @@ -53,7 +51,7 @@ public class WGLUtil { public static final boolean USE_WGLVersion_Of_5WGLGDIFuncSet; static { - USE_WGLVersion_Of_5WGLGDIFuncSet = Debug.isPropertyDefined("jogl.windows.useWGLVersionOf5WGLGDIFuncSet", true, AccessController.getContext()); + USE_WGLVersion_Of_5WGLGDIFuncSet = Debug.isPropertyDefined("jogl.windows.useWGLVersionOf5WGLGDIFuncSet", true); if(USE_WGLVersion_Of_5WGLGDIFuncSet) { System.err.println("Use WGL version of 5 WGL/GDI functions."); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java index 66088cc8c..579b11940 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java @@ -40,8 +40,6 @@ package jogamp.opengl.windows.wgl; -import java.security.AccessController; - import javax.media.nativewindow.NativeSurface; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; @@ -53,7 +51,7 @@ import jogamp.opengl.GLDynamicLookupHelper; public abstract class WindowsWGLDrawable extends GLDrawableImpl { - private static final boolean PROFILING = Debug.isPropertyDefined("jogl.debug.GLDrawable.profiling", true, AccessController.getContext()); + private static final boolean PROFILING = Debug.isPropertyDefined("jogl.debug.GLDrawable.profiling", true); private static final int PROFILING_TICKS = 200; private int profilingSwapBuffersTicks; private long profilingSwapBuffersTime; diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java index 6709344b5..48c4d31ce 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java @@ -40,7 +40,6 @@ package javax.media.nativewindow; -import java.security.AccessController; import java.util.List; import jogamp.nativewindow.Debug; @@ -67,7 +66,7 @@ import jogamp.nativewindow.Debug; */ public class DefaultCapabilitiesChooser implements CapabilitiesChooser { - private static final boolean DEBUG = Debug.isPropertyDefined("nativewindow.debug.CapabilitiesChooser", true, AccessController.getContext()); + private static final boolean DEBUG = Debug.isPropertyDefined("nativewindow.debug.CapabilitiesChooser", true); public int chooseCapabilities(final CapabilitiesImmutable desired, final List /**/ available, diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index b8cd41b84..16a4ecfe5 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -35,7 +35,6 @@ package javax.media.nativewindow; import java.lang.reflect.Constructor; import java.lang.reflect.Method; -import java.security.AccessControlContext; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Collections; @@ -191,9 +190,8 @@ public abstract class NativeWindowFactory { final ClassLoader cl = NativeWindowFactory.class.getClassLoader(); // Gather the windowing OS first - AccessControlContext acc = AccessController.getContext(); nativeWindowingTypePure = _getNativeWindowingType(); - String tmp = Debug.getProperty("nativewindow.ws.name", true, acc); + String tmp = Debug.getProperty("nativewindow.ws.name", true); if(null==tmp || tmp.length()==0) { nativeWindowingTypeCustom = nativeWindowingTypePure; } else { @@ -206,7 +204,7 @@ public abstract class NativeWindowFactory { } isAWTAvailable = false; // may be set to true below - if( !Debug.getBooleanProperty("java.awt.headless", true, acc) && + if( !Debug.getBooleanProperty("java.awt.headless", true) && ReflectionUtil.isClassAvailable(AWTComponentClassName, cl) && ReflectionUtil.isClassAvailable("com.jogamp.nativewindow.awt.AWTGraphicsDevice", cl) ) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java index 982ce469b..30f9660f0 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java @@ -29,7 +29,6 @@ package javax.media.nativewindow; import jogamp.nativewindow.Debug; -import java.security.AccessController; /** * Marker for a singleton global recursive blocking lock implementation, @@ -38,7 +37,7 @@ import java.security.AccessController; * One use case is the AWT locking on X11, see {@link jogamp.nativewindow.jawt.JAWTToolkitLock}. */ public interface ToolkitLock { - public static final boolean TRACE_LOCK = Debug.isPropertyDefined("nativewindow.debug.ToolkitLock.TraceLock", true, AccessController.getContext()); + public static final boolean TRACE_LOCK = Debug.isPropertyDefined("nativewindow.debug.ToolkitLock.TraceLock", true); public void lock(); public void unlock(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/Debug.java b/src/nativewindow/classes/jogamp/nativewindow/Debug.java index f1cd209dc..e07fd1b57 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/Debug.java +++ b/src/nativewindow/classes/jogamp/nativewindow/Debug.java @@ -39,18 +39,18 @@ package jogamp.nativewindow; -import java.security.*; +import com.jogamp.common.util.PropertyAccess; /** Helper routines for logging and debugging. */ -public class Debug { +public class Debug extends PropertyAccess { // Some common properties - private static boolean verbose; - private static boolean debugAll; - private static AccessControlContext localACC; + private static final boolean verbose; + private static final boolean debugAll; static { - localACC=AccessController.getContext(); + PropertyAccess.addTrustedPrefix("nativewindow.", Debug.class); + verbose = isPropertyDefined("nativewindow.verbose", true); debugAll = isPropertyDefined("nativewindow.debug", true); if (verbose) { @@ -61,71 +61,18 @@ public class Debug { } } - 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, acc)); - i = iv.intValue(); - } catch (NumberFormatException nfe) {} - return i; - } - - static boolean getBooleanProperty(final String property, final boolean jnlpAlias) { - return getBooleanProperty(property, jnlpAlias, localACC); + public static final boolean isPropertyDefined(final String property, final boolean jnlpAlias) { + return PropertyAccess.isPropertyDefined(property, jnlpAlias, null); } - - 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 String getProperty(final String property, final boolean jnlpAlias) { + return PropertyAccess.getProperty(property, jnlpAlias, null); } - - static boolean isPropertyDefined(final String property, final boolean jnlpAlias) { - return isPropertyDefined(property, jnlpAlias, localACC); + + public static final boolean getBooleanProperty(final String property, final boolean jnlpAlias) { + return PropertyAccess.getBooleanProperty(property, jnlpAlias, null); } - - public static boolean isPropertyDefined(final String property, final boolean jnlpAlias, final AccessControlContext acc) { - return (Debug.getProperty(property, jnlpAlias, acc) != null) ? true : false; - } - - 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." ; - + public static boolean verbose() { return verbose; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 4cbc1e367..c42bcf816 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -33,7 +33,6 @@ package jogamp.nativewindow.x11; -import java.security.AccessController; import java.util.ArrayList; import java.util.List; @@ -83,7 +82,7 @@ public class X11Util { public static final boolean HAS_XLOCKDISPLAY_BUG = true; private static final boolean DEBUG = Debug.debug("X11Util"); - private static final boolean TRACE_DISPLAY_LIFECYCLE = Debug.getBooleanProperty("nativewindow.debug.X11Util.TraceDisplayLifecycle", true, AccessController.getContext()); + private static final boolean TRACE_DISPLAY_LIFECYCLE = Debug.getBooleanProperty("nativewindow.debug.X11Util.TraceDisplayLifecycle", true); private static String nullDisplayName = null; private static boolean isX11LockAvailable = false; diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java index e71ef75ec..3b5e3a6fb 100644 --- a/src/newt/classes/com/jogamp/newt/util/MainThread.java +++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java @@ -39,8 +39,6 @@ package com.jogamp.newt.util; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; -import java.security.AccessControlContext; -import java.security.AccessController; import javax.media.nativewindow.NativeWindowFactory; @@ -101,11 +99,10 @@ public class MainThread { public static final boolean HINT_USE_MAIN_THREAD; static { - final AccessControlContext localACC = AccessController.getContext(); NativeWindowFactory.initSingleton(true); NEWTJNILibLoader.loadNEWT(); HINT_USE_MAIN_THREAD = !NativeWindowFactory.isAWTAvailable() || - Debug.getBooleanProperty("newt.MainThread.force", true, localACC); + Debug.getBooleanProperty("newt.MainThread.force", true); osType = Platform.getOSType(); isMacOSX = osType == Platform.OSType.MACOS; } diff --git a/src/newt/classes/jogamp/newt/Debug.java b/src/newt/classes/jogamp/newt/Debug.java index 85fbbe764..3c83da4d9 100644 --- a/src/newt/classes/jogamp/newt/Debug.java +++ b/src/newt/classes/jogamp/newt/Debug.java @@ -39,18 +39,17 @@ package jogamp.newt; -import java.security.*; +import com.jogamp.common.util.PropertyAccess; /** Helper routines for logging and debugging. */ -public class Debug { +public class Debug extends PropertyAccess { // Some common properties - private static boolean verbose; - private static boolean debugAll; - private static AccessControlContext localACC; + private static final boolean verbose; + private static final boolean debugAll; static { - localACC=AccessController.getContext(); + PropertyAccess.addTrustedPrefix("newt.", Debug.class); verbose = isPropertyDefined("newt.verbose", true); debugAll = isPropertyDefined("newt.debug", true); if (verbose) { @@ -61,71 +60,18 @@ public class Debug { } } - static int getIntProperty(final String property, final boolean jnlpAlias) { - return getIntProperty(property, jnlpAlias, localACC); + public static final boolean isPropertyDefined(final String property, final boolean jnlpAlias) { + return PropertyAccess.isPropertyDefined(property, jnlpAlias, null); } - - 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, acc)); - i = iv.intValue(); - } catch (NumberFormatException nfe) {} - return i; - } - - 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(); - } - - static boolean isPropertyDefined(final String property, final boolean jnlpAlias) { - return isPropertyDefined(property, jnlpAlias, localACC); - } - - public static boolean isPropertyDefined(final String property, final boolean jnlpAlias, final AccessControlContext acc) { - return (Debug.getProperty(property, jnlpAlias, acc) != null) ? true : false; - } - - static String getProperty(final String property, final boolean jnlpAlias) { - return getProperty(property, jnlpAlias, localACC); + + public static final int getIntProperty(final String property, final boolean jnlpAlias, int defaultValue) { + return PropertyAccess.getIntProperty(property, jnlpAlias, null, defaultValue); } - - 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 boolean getBooleanProperty(final String property, final boolean jnlpAlias) { + return PropertyAccess.getBooleanProperty(property, jnlpAlias, null); } - public static final String jnlp_prefix = "jnlp." ; - + public static boolean verbose() { return verbose; } diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index d4c6b6ee0..72f1b5a2c 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -34,7 +34,6 @@ package jogamp.newt; -import java.security.AccessControlContext; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; @@ -49,6 +48,7 @@ import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.SurfaceSize; + import com.jogamp.common.util.ArrayHashSet; import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.Display; @@ -78,7 +78,6 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { protected Dimension vSize = new Dimension(0, 0); // virtual rotated screen size protected static Dimension usrSize = null; // property values: newt.ws.swidth and newt.ws.sheight protected static volatile boolean usrSizeQueried = false; - private static AccessControlContext localACC = AccessController.getContext(); private ArrayList referencedScreenModeListener = new ArrayList(); private long tCreated; // creationTime @@ -121,8 +120,8 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { synchronized (Screen.class) { if(!usrSizeQueried) { usrSizeQueried = true; - final int w = Debug.getIntProperty("newt.ws.swidth", true, localACC); - final int h = Debug.getIntProperty("newt.ws.sheight", true, localACC); + final int w = Debug.getIntProperty("newt.ws.swidth", true, 0); + final int h = Debug.getIntProperty("newt.ws.sheight", true, 0); if(w>0 && h>0) { usrSize = new Dimension(w, h); System.err.println("User screen size "+usrSize); -- cgit v1.2.3