summaryrefslogtreecommitdiffstats
path: root/src/nativewindow
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-08-19 12:14:07 +0200
committerSven Gothel <[email protected]>2019-08-19 12:14:07 +0200
commit13c6bbbde5ea476d60e0a2f04a5172d3302d0edd (patch)
treee2ca3b4cd685abd315ea57c9ad1f762129c7fc70 /src/nativewindow
parente1c8add69973b0eae9a87cf2181a0f1cbbe62f4b (diff)
Bug 1363: Java 11: Don't use sun.awt.SunToolkit.awtLock/Unlock on Java9+ [illegal reflective access]
Avoid illegal reflective access to sun.awt.SunToolkit.awtLock/Unlock on Java9+ Apparently these give a performance benefit on X11 by avoiding taking the AWT global lock, and instead only taking a Java lock defined in sun.awt.SunToolkit. But this has thrown a warning since Java 9, and will soon be illegal. If a performance problem remains on X11, we'll need to find another solution. Orig patch by Wade Walker. This patch only skips utilizing said API on Java9+ while maintaining orig code path for Java8.
Diffstat (limited to 'src/nativewindow')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
index 0f4a70ddc..6158e792e 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
@@ -91,6 +91,8 @@ public class JAWTUtil {
private static final Method isQueueFlusherThread;
private static final boolean j2dExist;
+ // Unavailable since Java_9
+ // 'illegal reflective access to sun.awt.SunToolkit.awtLock/Unlock'
private static final Method sunToolkitAWTLockMethod;
private static final Method sunToolkitAWTUnlockMethod;
private static final boolean hasSunToolkitAWTLock;
@@ -354,15 +356,19 @@ public class JAWTUtil {
@Override
public Object run() {
final PrivilegedDataBlob1 d = new PrivilegedDataBlob1();
- try {
- final Class<?> sunToolkitClass = Class.forName("sun.awt.SunToolkit");
- d.sunToolkitAWTLockMethod = sunToolkitClass.getDeclaredMethod("awtLock", new Class[]{});
- d.sunToolkitAWTLockMethod.setAccessible(true);
- d.sunToolkitAWTUnlockMethod = sunToolkitClass.getDeclaredMethod("awtUnlock", new Class[]{});
- d.sunToolkitAWTUnlockMethod.setAccessible(true);
- d.ok=true;
- } catch (final Exception e) {
- // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5
+ if( PlatformPropsImpl.JAVA_9 ) {
+ d.ok=false;
+ } else {
+ try {
+ final Class<?> sunToolkitClass = Class.forName("sun.awt.SunToolkit");
+ d.sunToolkitAWTLockMethod = sunToolkitClass.getDeclaredMethod("awtLock", new Class[]{});
+ d.sunToolkitAWTLockMethod.setAccessible(true);
+ d.sunToolkitAWTUnlockMethod = sunToolkitClass.getDeclaredMethod("awtUnlock", new Class[]{});
+ d.sunToolkitAWTUnlockMethod.setAccessible(true);
+ d.ok=true;
+ } catch (final Exception e) {
+ // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5
+ }
}
try {
final GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
@@ -392,7 +398,6 @@ public class JAWTUtil {
}
}
hasSunToolkitAWTLock = _hasSunToolkitAWTLock;
- // hasSunToolkitAWTLock = false;
}
jawtLock = LockFactory.createRecursiveLock();