From fd5734e99be82efdefcf07b999539470c407f01a Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Sat, 3 May 2014 09:01:19 -0700 Subject: j3dcore: small style change to do an early return when the appContext does not need checking Signed-off-by: Harvey Harrison --- .../share/javax/media/j3d/JoglPipeline.java | 37 +++++++++++----------- 1 file 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. -- cgit v1.2.3