summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com/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/com/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/com/jogamp')
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java59
1 files changed, 2 insertions, 57 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index a0083b4ea..66f50781f 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -31,7 +31,6 @@ package com.jogamp.newt.awt;
import java.applet.Applet;
import java.awt.AWTKeyStroke;
-import java.awt.Canvas;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.Graphics;
@@ -43,9 +42,6 @@ import java.awt.geom.NoninvertibleTransformException;
import java.beans.Beans;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.Set;
import com.jogamp.nativewindow.CapabilitiesImmutable;
@@ -593,7 +589,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements NativeWindowHolder
* This code order also allows recreation, ie re-adding the GLCanvas.
*/
// before native peer is valid: X11
- disableBackgroundErase();
+ JAWTUtil.disableBackgroundErase(this);
// Query AWT GraphicsDevice from parent tree, default
final GraphicsConfiguration gc = super.getGraphicsConfiguration();
@@ -611,7 +607,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements NativeWindowHolder
super.addNotify();
// after native peer is valid: Windows
- disableBackgroundErase();
+ JAWTUtil.disableBackgroundErase(this);
synchronized(sync) {
determineIfApplet();
@@ -1119,57 +1115,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements NativeWindowHolder
}
}
- // 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(DEBUG) {
- System.err.println("NewtCanvasAWT: TK disableBackgroundErase method found: "+
- (null!=disableBackgroundEraseMethod));
- }
- }
- if (disableBackgroundEraseMethod != null) {
- Throwable t=null;
- try {
- disableBackgroundEraseMethod.invoke(getToolkit(), new Object[] { this });
- } catch (final Exception e) {
- t = e;
- }
- if(DEBUG) {
- System.err.println("NewtCanvasAWT: TK disableBackgroundErase error: "+t);
- }
- }
- }
-
protected static String currentThreadName() { return "["+Thread.currentThread().getName()+", isAWT-EDT "+EventQueue.isDispatchThread()+"]"; }
static String newtWinHandleToHexString(final Window w) {