summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2014-05-03 09:01:19 -0700
committerHarvey Harrison <[email protected]>2014-05-03 09:01:19 -0700
commitfd5734e99be82efdefcf07b999539470c407f01a (patch)
treead5a47036baa2ce04ff09010a0a1b3b2acd7a097
parentbdda2ac20bfef85271da764d1989ec3434d5c67a (diff)
j3dcore: small style change to do an early return when the appContext does not need checking
Signed-off-by: Harvey Harrison <[email protected]>
-rw-r--r--src/classes/share/javax/media/j3d/JoglPipeline.java37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/classes/share/javax/media/j3d/JoglPipeline.java b/src/classes/share/javax/media/j3d/JoglPipeline.java
index 3f7384d..ca7f5dc 100644
--- a/src/classes/share/javax/media/j3d/JoglPipeline.java
+++ b/src/classes/share/javax/media/j3d/JoglPipeline.java
@@ -6365,25 +6365,26 @@ class JoglPipeline extends Pipeline {
// Fix for Bug 983
private void checkAppContext() {
- if (mainThreadContext != null) {
- try {
- // Check by reflection that sun.awt.AppContext.getAppContext() doesn't return null
- // (required by ImageIO.write() and other JMF internal calls) to apply workaround proposed at
- // http://stackoverflow.com/questions/17223304/appcontext-is-null-from-rmi-thread-with-java-7-update-25
- final Class<?> appContextClass = Class.forName("sun.awt.AppContext");
- if (appContextClass.getMethod("getAppContext").invoke(null) == null) {
- final Field field = appContextClass.getDeclaredField("threadGroup2appContext");
- field.setAccessible(true);
- final Map threadGroup2appContext = (Map)field.get(null);
- final ThreadGroup currentThreadGroup = Thread.currentThread().getThreadGroup();
- threadGroup2appContext.put(currentThreadGroup, mainThreadContext);
- }
- } catch (final Throwable ex) {
- // Let's consider app context is not necessary for the program
- }
- // Don't need mainThreadContext anymore
- mainThreadContext = null;
+ if (mainThreadContext == null)
+ return;
+
+ try {
+ // Check by reflection that sun.awt.AppContext.getAppContext() doesn't return null
+ // (required by ImageIO.write() and other JMF internal calls) to apply workaround proposed at
+ // http://stackoverflow.com/questions/17223304/appcontext-is-null-from-rmi-thread-with-java-7-update-25
+ final Class<?> appContextClass = Class.forName("sun.awt.AppContext");
+ if (appContextClass.getMethod("getAppContext").invoke(null) == null) {
+ final Field field = appContextClass.getDeclaredField("threadGroup2appContext");
+ field.setAccessible(true);
+ final Map threadGroup2appContext = (Map)field.get(null);
+ final ThreadGroup currentThreadGroup = Thread.currentThread().getThreadGroup();
+ threadGroup2appContext.put(currentThreadGroup, mainThreadContext);
+ }
+ } catch (Throwable ex) {
+ // Let's consider app context is not necessary for the program
}
+ // Don't need mainThreadContext anymore
+ mainThreadContext = null;
}
// This is the native method for creating the underlying graphics context.