aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorphil <[email protected]>2019-09-21 17:11:40 +1200
committerphil <[email protected]>2019-09-21 17:11:40 +1200
commit8eb67b58cee5017ff62affdc54806c0edd6735b6 (patch)
tree92cae60eabcdfa4b0ef16818cee94e8cc713aec1 /src
parent1775dd20eec91ef26ed03741a1d24a9d04a85833 (diff)
checkAppContext only applies to java version 7 and 8 now
and thus the "An illegal reflective access operation has occurred" warning in Java 10 is no longer displayed
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/jogamp/java3d/JoglPipeline.java34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/main/java/org/jogamp/java3d/JoglPipeline.java b/src/main/java/org/jogamp/java3d/JoglPipeline.java
index f386f0b..0b727a6 100644
--- a/src/main/java/org/jogamp/java3d/JoglPipeline.java
+++ b/src/main/java/org/jogamp/java3d/JoglPipeline.java
@@ -105,20 +105,28 @@ class JoglPipeline extends Pipeline {
private GLProfile profile;
- private Object mainThreadContext; // Fix for Bug 983
+ private Object mainThreadContext; // Fix for Bug 983 (on java 7 or 8 only)
/**
* Constructor for singleton JoglPipeline instance
*/
protected JoglPipeline() {
- // Fix for Bug 983
- try {
- // Retrieve main thread AppContext instance by reflection
- mainThreadContext = Class.forName("sun.awt.AppContext").getMethod("getAppContext").invoke(null);
- } catch (final Throwable ex) {
- // Let's consider app context is not necessary for the program
- }
+ // https://bugs.openjdk.java.net/browse/JDK-8019274 fixed in Java 8 and the work around for mainThreadContext
+ // causes WARNING: An illegal reflective access operation has occurred in Java 10
+ // so this work around enabled on for java 7 or 8
+ int javaVersion = getVersion();
+ if(javaVersion == 7 || javaVersion ==8)
+ {
+ // Fix for Bug 983
+ try {
+ // Retrieve main thread AppContext instance by reflection
+ mainThreadContext = Class.forName("sun.awt.AppContext").getMethod("getAppContext").invoke(null);
+ } catch (final Throwable ex) {
+ // Let's consider app context is not necessary for the program
+ }
+ }
}
+
/**
* Initialize the pipeline
@@ -9020,4 +9028,14 @@ static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height)
return bufs;
}
+
+ private static int getVersion() {
+ String version = System.getProperty("java.version");
+ if(version.startsWith("1.")) {
+ version = version.substring(2, 3);
+ } else {
+ int dot = version.indexOf(".");
+ if(dot != -1) { version = version.substring(0, dot); }
+ } return Integer.parseInt(version);
+ }
}