diff options
Diffstat (limited to 'src/nativewindow')
3 files changed, 84 insertions, 53 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AppContextInfo.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AppContextInfo.java index e5dcfa1c0..8189f6262 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AppContextInfo.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AppContextInfo.java @@ -5,7 +5,9 @@ import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; +import com.jogamp.common.ExceptionUtils; import com.jogamp.common.util.RunnableTask; +import com.jogamp.common.util.UnsafeUtil; import jogamp.nativewindow.jawt.JAWTUtil; @@ -29,15 +31,18 @@ public class AppContextInfo { AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { - try { - final Class<?> appContextClass = Class.forName("sun.awt.AppContext"); - _getAppContextMethod[0] = appContextClass.getMethod("getAppContext"); - } catch(final Throwable ex) { - System.err.println("Bug 1004: Caught @ static: "+ex.getMessage()); - ex.printStackTrace(); - } - return null; - } } ); + return UnsafeUtil.doWithoutIllegalAccessLogger(new PrivilegedAction<Object>() { + @Override + public Object run() { + try { + final Class<?> appContextClass = Class.forName("sun.awt.AppContext"); + _getAppContextMethod[0] = appContextClass.getMethod("getAppContext"); + _getAppContextMethod[0].setAccessible(true); + } catch(final Throwable ex) { + ExceptionUtils.dumpThrowable("AppContextInfo(Bug 1004)", ex); + } + return null; + }}); }}); getAppContextMethod = _getAppContextMethod[0]; } @@ -185,8 +190,7 @@ public class AppContextInfo { try { return getAppContextMethod.invoke(null); } catch(final Exception ex) { - System.err.println("Bug 1004: Caught: "+ex.getMessage()); - ex.printStackTrace(); + ExceptionUtils.dumpThrowable("AppContextInfo(Bug 1004)", ex); return null; } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java index 40fdaa296..55aaf90d2 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java @@ -47,50 +47,62 @@ import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; +import com.jogamp.common.ExceptionUtils; +import com.jogamp.common.util.UnsafeUtil; import com.jogamp.nativewindow.AbstractGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; +import jogamp.nativewindow.jawt.JAWTUtil; + /** This class encapsulates the reflection routines necessary to peek inside a few data structures in the AWT implementation on X11 for the purposes of correctly enumerating the available visuals. */ public class Win32SunJDKReflection { - private static Class win32GraphicsDeviceClass; - private static Class win32GraphicsConfigClass; - private static Method win32GraphicsConfigGetConfigMethod; - private static Method win32GraphicsConfigGetVisualMethod; - private static boolean initted; + private static Class<?> win32GraphicsDeviceClass; + private static Class<?> win32GraphicsConfigClass; + private static Method win32GraphicsConfigGetConfigMethod; + private static Method win32GraphicsConfigGetVisualMethod; + private static boolean initialized; static { - AccessController.doPrivileged(new PrivilegedAction() { + AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { - try { - win32GraphicsDeviceClass = Class.forName("sun.awt.Win32GraphicsDevice"); - win32GraphicsConfigClass = Class.forName("sun.awt.Win32GraphicsConfig"); - win32GraphicsConfigGetConfigMethod = win32GraphicsConfigClass.getDeclaredMethod("getConfig", new Class[] { win32GraphicsDeviceClass, int.class }); - win32GraphicsConfigGetConfigMethod.setAccessible(true); - win32GraphicsConfigGetVisualMethod = win32GraphicsConfigClass.getDeclaredMethod("getVisual", new Class[] {}); - win32GraphicsConfigGetVisualMethod.setAccessible(true); - initted = true; - } catch (final Exception e) { - // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5 - } - return null; - } - }); + return UnsafeUtil.doWithoutIllegalAccessLogger(new PrivilegedAction<Object>() { + @Override + public Object run() { + try { + win32GraphicsDeviceClass = Class.forName("sun.awt.Win32GraphicsDevice"); + win32GraphicsConfigClass = Class.forName("sun.awt.Win32GraphicsConfig"); + win32GraphicsConfigGetConfigMethod = win32GraphicsConfigClass.getDeclaredMethod("getConfig", win32GraphicsDeviceClass, int.class); + win32GraphicsConfigGetConfigMethod.setAccessible(true); + win32GraphicsConfigGetVisualMethod = win32GraphicsConfigClass.getDeclaredMethod("getVisual"); + win32GraphicsConfigGetVisualMethod.setAccessible(true); + initialized = true; + } catch (final Exception e) { + // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5 + if( JAWTUtil.DEBUG ) { + ExceptionUtils.dumpThrowable("Win32SunJDKReflection", e); + } + } + return null; + }}); }}); } public static GraphicsConfiguration graphicsConfigurationGet(final GraphicsDevice device, final int pfdID) { - if (!initted) { + if (!initialized) { return null; } try { - return (GraphicsConfiguration) win32GraphicsConfigGetConfigMethod.invoke(null, new Object[] { device, Integer.valueOf(pfdID) }); + return (GraphicsConfiguration) win32GraphicsConfigGetConfigMethod.invoke(null, device, Integer.valueOf(pfdID)); } catch (final Exception e) { + if( JAWTUtil.DEBUG ) { + ExceptionUtils.dumpThrowable("Win32SunJDKReflection", e); + } return null; } } @@ -107,13 +119,16 @@ public class Win32SunJDKReflection { } public static int graphicsConfigurationGetPixelFormatID(final GraphicsConfiguration config) { - if (!initted) { + if (!initialized) { return 0; } try { - return ((Integer) win32GraphicsConfigGetVisualMethod.invoke(config, (Object[])null)).intValue(); + return ((Integer) win32GraphicsConfigGetVisualMethod.invoke(config)).intValue(); } catch (final Exception e) { + if( JAWTUtil.DEBUG ) { + ExceptionUtils.dumpThrowable("Win32SunJDKReflection", e); + } return 0; } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java index 3ae3b4840..d86704c07 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java @@ -47,10 +47,13 @@ import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; +import com.jogamp.common.ExceptionUtils; +import com.jogamp.common.util.UnsafeUtil; import com.jogamp.nativewindow.AbstractGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; +import jogamp.nativewindow.jawt.JAWTUtil; /** This class encapsulates the reflection routines necessary to peek inside a few data structures in the AWT implementation on X11 for @@ -67,31 +70,38 @@ public class X11SunJDKReflection { AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { - try { - x11GraphicsDeviceClass = Class.forName("sun.awt.X11GraphicsDevice"); - x11GraphicsDeviceGetDisplayMethod = x11GraphicsDeviceClass.getDeclaredMethod("getDisplay", new Class[] {}); - x11GraphicsDeviceGetDisplayMethod.setAccessible(true); + return UnsafeUtil.doWithoutIllegalAccessLogger(new PrivilegedAction<Object>() { + @Override + public Object run() { + try { + x11GraphicsDeviceClass = Class.forName("sun.awt.X11GraphicsDevice"); + x11GraphicsDeviceGetDisplayMethod = x11GraphicsDeviceClass.getDeclaredMethod("getDisplay"); + x11GraphicsDeviceGetDisplayMethod.setAccessible(true); - x11GraphicsConfigClass = Class.forName("sun.awt.X11GraphicsConfig"); - x11GraphicsConfigGetVisualMethod = x11GraphicsConfigClass.getDeclaredMethod("getVisual", new Class[] {}); - x11GraphicsConfigGetVisualMethod.setAccessible(true); - initialized = true; - } catch (final Exception e) { - // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5 - } - return null; - } - }); + x11GraphicsConfigClass = Class.forName("sun.awt.X11GraphicsConfig"); + x11GraphicsConfigGetVisualMethod = x11GraphicsConfigClass.getDeclaredMethod("getVisual"); + x11GraphicsConfigGetVisualMethod.setAccessible(true); + initialized = true; + } catch (final Exception e) { + // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5 + if( JAWTUtil.DEBUG ) { + ExceptionUtils.dumpThrowable("X11SunJDKReflection", e); + } + } + return null; + }}); }}); } public static long graphicsDeviceGetDisplay(final GraphicsDevice device) { if (!initialized) { return 0; } - try { - return ((Long) x11GraphicsDeviceGetDisplayMethod.invoke(device, (Object[])null)).longValue(); + return ((Long) x11GraphicsDeviceGetDisplayMethod.invoke(device)).longValue(); } catch (final Exception e) { + if( JAWTUtil.DEBUG ) { + ExceptionUtils.dumpThrowable("X11SunJDKReflection", e); + } return 0; } } @@ -111,10 +121,12 @@ public class X11SunJDKReflection { if (!initialized) { return 0; } - try { - return ((Integer) x11GraphicsConfigGetVisualMethod.invoke(config, (Object[])null)).intValue(); + return ((Integer) x11GraphicsConfigGetVisualMethod.invoke(config)).intValue(); } catch (final Exception e) { + if( JAWTUtil.DEBUG ) { + ExceptionUtils.dumpThrowable("X11SunJDKReflection", e); + } return 0; } } |