static { JAWTJNILibLoader.loadAWTImpl(); JAWTJNILibLoader.loadNativeWindow("awt"); headlessMode = GraphicsEnvironment.isHeadless(); boolean ok = false; Class jC = null; Method m = null; if (!headlessMode) { try { jC = Class.forName("com.jogamp.opengl.impl.awt.Java2D"); m = jC.getMethod("isQueueFlusherThread", null); ok = true; } catch (Exception e) { } } j2dClazz = jC; isQueueFlusherThread = m; j2dExist = ok; AccessController.doPrivileged( new PrivilegedAction() { public Object run() { try { sunToolkitClass = Class.forName("sun.awt.SunToolkit"); sunToolkitAWTLockMethod = sunToolkitClass.getDeclaredMethod("awtLock", new Class[] {}); sunToolkitAWTLockMethod.setAccessible(true); sunToolkitAWTUnlockMethod = sunToolkitClass.getDeclaredMethod("awtUnlock", new Class[] {}); sunToolkitAWTUnlockMethod.setAccessible(true); } catch (Exception e) { // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5 } return null; } }); boolean _hasSunToolkitAWTLock = false; if (null != sunToolkitAWTLockMethod && null != sunToolkitAWTUnlockMethod) { try { sunToolkitAWTLockMethod.invoke(null, null); sunToolkitAWTUnlockMethod.invoke(null, null); _hasSunToolkitAWTLock = true; } catch (Exception e) { } } hasSunToolkitAWTLock = _hasSunToolkitAWTLock; // useSunToolkitAWTLock = hasSunToolkitAWTLock; useSunToolkitAWTLock = false; }
public void run() { if (useMainThread) { // we have to start first to provide the service .. singletonMainThread.waitUntilRunning(); } // start user app .. try { Class mainClass = ReflectionUtil.getClass(mainClassName, true, getClass().getClassLoader()); if (null == mainClass) { throw new RuntimeException( new ClassNotFoundException("MainThread couldn't find main class " + mainClassName)); } try { mainClassMain = mainClass.getDeclaredMethod("main", new Class[] {String[].class}); mainClassMain.setAccessible(true); } catch (Throwable t) { throw new RuntimeException(t); } if (DEBUG) System.err.println( "MainAction.run(): " + Thread.currentThread().getName() + " invoke " + mainClassName); mainClassMain.invoke(null, new Object[] {mainClassArgs}); } catch (InvocationTargetException ite) { ite.getTargetException().printStackTrace(); } catch (Throwable t) { t.printStackTrace(); } if (DEBUG) System.err.println( "MainAction.run(): " + Thread.currentThread().getName() + " user app fin"); if (useMainThread) { singletonMainThread.stop(); if (DEBUG) System.err.println( "MainAction.run(): " + Thread.currentThread().getName() + " MainThread fin - stop"); System.exit(0); } }
public static void main(String[] args) { int type = USE_NEWT; String tstName = "demos.es2.perftst.PerfVBOLoad"; // default for (int i = args.length - 1; i >= 0; i--) { if (args[i].equals("-awt")) { type |= USE_AWT; } if (args[i].equals("-test") && i + 1 < args.length) { tstName = args[i + 1]; } } try { PerfModule pmod = (PerfModule) Class.forName(tstName).newInstance(); new Perftst().run(type, pmod); System.exit(0); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }