summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-09-04 04:20:22 +0200
committerSven Gothel <[email protected]>2019-09-04 04:20:22 +0200
commitc5431f46b7bf64f109315ec78461859dd88f202a (patch)
treed5952708d0d1460bb299a04e95a126f919f7e5ba /src/newt/classes/jogamp
parentd1f4bcc64222d53eb7241184210730aa28ae1f6d (diff)
Bug 1363: Java 11: JAWTUtil: Use sun.awt.SunToolkit.awtLock/Unlock and disableBackgroundErase (impl. semantics)
Commit 13c6bbbde5ea476d60e0a2f04a5172d3302d0edd simply removed the AWT commonly used SunToolkit lock/unlock methods, which was incorrect. It lead to certain resources access collisions as access has to be synchronized using the same reentry lock across AWT and NativeWindow/JOGL. We utilize the new com.jogamp.common.util.UnsafeUtil of GlueGen commit 07c1885e9a3d1f3a3853414648c06fb3864bc69f to disable the IllegalAccessLogger while fetching the methods/fields and making them accessible. JAWUtil also hosts access to SunToolkit's disableBackgroundAccess(Component) aligning the code for GLCanvas, NewtCanvasAWT and AWTCanvas.
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java62
1 files changed, 4 insertions, 58 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java
index bdf78386a..b81bd7544 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java
@@ -38,9 +38,6 @@ import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsConfiguration;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import com.jogamp.nativewindow.AbstractGraphicsDevice;
import com.jogamp.nativewindow.AbstractGraphicsScreen;
@@ -58,6 +55,8 @@ import com.jogamp.nativewindow.awt.AWTGraphicsScreen;
import com.jogamp.nativewindow.awt.JAWTWindow;
import com.jogamp.newt.Window;
+import jogamp.nativewindow.jawt.JAWTUtil;
+
@SuppressWarnings("serial")
public class AWTCanvas extends Canvas {
private final WindowDriver driver;
@@ -122,7 +121,7 @@ public class AWTCanvas extends Canvas {
public void addNotify() {
// before native peer is valid: X11
- disableBackgroundErase();
+ JAWTUtil.disableBackgroundErase(this);
/**
* 'super.addNotify()' determines the GraphicsConfiguration,
@@ -147,7 +146,7 @@ public class AWTCanvas extends Canvas {
super.addNotify();
// after native peer is valid: Windows
- disableBackgroundErase();
+ JAWTUtil.disableBackgroundErase(this);
{
jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig);
@@ -347,57 +346,4 @@ public class AWTCanvas extends Canvas {
return config;
}
-
- // Disables the AWT's erasing of this Canvas's background on Windows
- // in Java SE 6. This internal API is not available in previous
- // releases, but the system property
- // -Dsun.awt.noerasebackground=true can be specified to get similar
- // results globally in previous releases.
- private static boolean disableBackgroundEraseInitialized;
- private static Method disableBackgroundEraseMethod;
- private void disableBackgroundErase() {
- if (!disableBackgroundEraseInitialized) {
- try {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- @Override
- public Object run() {
- try {
- Class<?> clazz = getToolkit().getClass();
- while (clazz != null && disableBackgroundEraseMethod == null) {
- try {
- disableBackgroundEraseMethod =
- clazz.getDeclaredMethod("disableBackgroundErase",
- new Class[] { Canvas.class });
- disableBackgroundEraseMethod.setAccessible(true);
- } catch (final Exception e) {
- clazz = clazz.getSuperclass();
- }
- }
- } catch (final Exception e) {
- }
- return null;
- }
- });
- } catch (final Exception e) {
- }
- disableBackgroundEraseInitialized = true;
- if(Window.DEBUG_IMPLEMENTATION) {
- System.err.println("AWTCanvas: TK disableBackgroundErase method found: "+
- (null!=disableBackgroundEraseMethod));
- }
- }
- if (disableBackgroundEraseMethod != null) {
- Throwable t=null;
- try {
- disableBackgroundEraseMethod.invoke(getToolkit(), new Object[] { this });
- } catch (final Exception e) {
- // FIXME: workaround for 6504460 (incorrect backport of 6333613 in 5.0u10)
- // throw new GLException(e);
- t = e;
- }
- if(Window.DEBUG_IMPLEMENTATION) {
- System.err.println("AWTCanvas: TK disableBackgroundErase error: "+t);
- }
- }
- }
}