public Object findJType(String name) { try { return ReflectionUtils.invokeMethod(impl, "findJType(java.lang.String)", name); } catch (Throwable e) { throw ReflectionUtils.propagate(e); } }
public ClassLoader getClassLoader() { // returns CompilingClassLoader try { return (ClassLoader) ReflectionUtils.invokeMethod2(moduleSpaceHost, "getClassLoader"); } catch (Throwable e) { throw ReflectionUtils.propagate(e); } }
public int getDispId(String member) { try { return (Integer) ReflectionUtils.invokeMethod( dispatchIdOracleImpl, "getDispId(java.lang.String)", member); } catch (Throwable e) { throw ReflectionUtils.propagate(e); } }
public void invalidateRebind(String typeName) { try { browserShell.getModuleSpace().invalidateRebind(typeName); } catch (Throwable e) { ReflectionUtils.propagate(e); } }
//////////////////////////////////////////////////////////////////////////// // // Template // //////////////////////////////////////////////////////////////////////////// protected final InputStream getTemplate2(String path) { try { return Activator.getFile("templates/" + path); } catch (Throwable e) { throw ReflectionUtils.propagate(e); } }
//////////////////////////////////////////////////////////////////////////// // // Listeners // //////////////////////////////////////////////////////////////////////////// @Override protected void refresh_afterCreate() throws Exception { if (!isPlaceholder()) { ReflectionUtils.invokeMethod(getObject(), "layout(boolean)", true); } super.refresh_afterCreate(); }
public DispatchIdOracle getDispatchIdOracle(Object delegate) throws Exception { if (dispatchIdOracle == null) { final Object dispatchIdOracleImpl = ReflectionUtils.invokeMethod2(delegate, "getDispatchIdOracle"); dispatchIdOracle = new DispatchIdOracleImpl(dispatchIdOracleImpl); } return dispatchIdOracle; }
@SuppressWarnings("rawtypes") public void invokeNativeVoid(String string, Class[] classes, Object[] objects) { try { browserShell.getModuleSpace().invokeNativeVoid(string, null, classes, objects); } catch (Throwable e) { throw ReflectionUtils.propagate(e); } }
public Object createModuleSpace(String moduleName, Object msHost, ModuleSpace delegateModuleSpace) throws Exception { return ReflectionUtils.invokeMethod( impl, "createDelegatingModuleSpace(java.lang.Object,java.lang.String,java.lang.Object)", msHost, moduleName, delegateModuleSpace); }
//////////////////////////////////////////////////////////////////////////// // // Java source // //////////////////////////////////////////////////////////////////////////// @Override protected String getJavaSourceToAssert() { try { IType type = m_javaProject.findType("test.client.Test"); return type.getCompilationUnit().getSource(); } catch (Throwable e) { throw ReflectionUtils.propagate(e); } }
public DispatchClassInfo getClassInfoByDispId(int dispId) { try { final Object dispatchClassInfo = ReflectionUtils.invokeMethod(dispatchIdOracleImpl, "getClassInfoByDispId(int)", dispId); return new DispatchClassInfo() { public Member getMember(int dispId) { try { return (Member) ReflectionUtils.invokeMethod(dispatchClassInfo, "getMember(int)", dispId); } catch (Throwable e) { throw ReflectionUtils.propagate(e); } } }; } catch (Throwable e) { throw ReflectionUtils.propagate(e); } }
//////////////////////////////////////////////////////////////////////////// // // IHostedModeSupport // //////////////////////////////////////////////////////////////////////////// public void startup( String browserStartupUrl, String moduleName, IProgressMonitor monitor, int timeout) throws Exception { browserShell.setUrl( browserStartupUrl, moduleName, timeout, new Runnable() { public void run() { runMessagesLoop(); } }); // setup parent for CompilingClassLoader ClassLoader classLoader = getClassLoader(); ReflectionUtils.setField(classLoader, "parent", parentClassLoader); }
//////////////////////////////////////////////////////////////////////////// // // IBrowserShellHost // //////////////////////////////////////////////////////////////////////////// public Object createModuleSpaceHost(String moduleName) throws Exception { ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(getDevClassLoader()); try { initializePersistentUnitCache(); // create ShellModuleSpaceHost moduleSpaceHost = ReflectionUtils.invokeMethod( impl, "createModuleSpaceHost(java.lang.String,java.io.File,java.lang.String)", moduleName, null, getUserAgent()); return moduleSpaceHost; } finally { Thread.currentThread().setContextClassLoader(oldContextClassLoader); } }
private static void setSize(WidgetInfo widget, double size) { String signature = "setSize(" + WidgetInfo.class.getName() + ",double)"; ReflectionUtils.invokeMethodEx(widget.getParent(), signature, widget, size); }
private static Double getSize(WidgetInfo widget) { String signature = "getSize(" + WidgetInfo.class.getName() + ")"; return (Double) ReflectionUtils.invokeMethodEx(widget.getParent(), signature, widget); }
public void dispose() { if (moduleSpaceHost != null) { // clear static caches ClassLoader devClassLoader = getDevClassLoader(); try { Class<?> clazz = devClassLoader.loadClass("com.google.gwt.i18n.rebind.ClearStaticData"); ReflectionUtils.invokeMethod2(clazz, "clear"); } catch (Throwable e) { } try { Class<?> clazz = devClassLoader.loadClass("com.google.gwt.uibinder.rebind.model.OwnerFieldClass"); Map<?, ?> map = (Map<?, ?>) ReflectionUtils.getFieldObject(clazz, "FIELD_CLASSES"); map.clear(); } catch (Throwable e) { } // remove parent of CompilingClassLoader if (parentClassLoader != null) { ClassLoader classLoader = getClassLoader(); ReflectionUtils.setField(classLoader, "parent", null); } // clear "loadedModulesCaches" in com.google.gwt.dev.cfg.ModuleDefLoader try { Class<?> moduleDefLoader = devClassLoader.loadClass("com.google.gwt.dev.cfg.ModuleDefLoader"); Map<?, ?> loadedModulesCaches = (Map<?, ?>) ReflectionUtils.getFieldObject(moduleDefLoader, "loadedModulesCaches"); loadedModulesCaches.clear(); } catch (Throwable e) { } /*// clear "threadLocalLogger" in com.google.gwt.dev.shell.ModuleSpace try { Class<?> classModuleSpace = devClassLoader.loadClass("com.google.gwt.dev.shell.ModuleSpace"); ThreadLocal<?> threadLocalLogger = (ThreadLocal<?>) ReflectionUtils.getFieldObject(classModuleSpace, "threadLocalLogger"); threadLocalLogger.set(null); } catch (Throwable e) { } // shutdown com.google.gwt.dev.javac.PersistentUnitCache try { Class<?> classUnitCacheFactory = devClassLoader.loadClass("com.google.gwt.dev.javac.UnitCacheFactory"); Object cacheInstance = ReflectionUtils.getFieldObject(classUnitCacheFactory, "instance"); if (cacheInstance != null) { Method shutdownMethod = ReflectionUtils.getMethodBySignature(cacheInstance.getClass(), "shutdown()"); if (shutdownMethod != null) { shutdownMethod.invoke(cacheInstance); } } ReflectionUtils.setField(classUnitCacheFactory, "instance", null); } catch (Throwable e) { } // Call and remove GWT related java.lang.ApplicationShutdownHooks try { Class<?> hooksClass = ClassLoader.getSystemClassLoader().loadClass("java.lang.ApplicationShutdownHooks"); Field hooksField = ReflectionUtils.getFieldByName(hooksClass, "hooks"); @SuppressWarnings("unchecked") Map<Thread, ?> hooks = (Map<Thread, ?>) hooksField.get(null); List<Thread> threads = ImmutableList.copyOf(hooks.keySet()); for (Thread thread : threads) { ClassLoader contextClassLoader = thread.getContextClassLoader(); if (contextClassLoader == devClassLoader) { thread.setContextClassLoader(ClassLoader.getSystemClassLoader()); thread.run(); hooks.remove(thread); } } } catch (Throwable e) { e.printStackTrace(); } // close com.google.gwt.dev.util.DiskCache try { Class<?> classDiskCache = devClassLoader.loadClass("com.google.gwt.dev.util.DiskCache"); Object cacheInstance = ReflectionUtils.getFieldObject(classDiskCache, "INSTANCE"); ReflectionUtils.invokeMethod(cacheInstance, "close()"); } catch (Throwable e) { } // find embedded Guava Finalizer and clear reference of our "dev" URLClassLoader try { Thread[] threads = getAllThreads(); for (Thread thread : threads) { if (thread != null && thread.getContextClassLoader() == devClassLoader) { thread.setContextClassLoader(null); } } } catch (Throwable e) { }*/ } // if (browserShell != null) { browserShell.dispose(); } logSupport.dispose(); moduleSpaceHost = null; impl = null; projectClassLoader = null; dispatchIdOracle = null; }
//////////////////////////////////////////////////////////////////////////// // // Refresh // //////////////////////////////////////////////////////////////////////////// @Override protected void refresh_fetch() throws Exception { ReflectionUtils.invokeMethod(getObject(), "expandMenu()"); super.refresh_fetch(); ReflectionUtils.invokeMethod(getObject(), "deactivate()"); }