/** * Get the current Context. * * The current Context is per-thread; this method looks up * the Context associated with the current thread. <p> * * @return the Context associated with the current thread, or * null if no context is associated with the current * thread. * @see ContextFactory#enterContext() * @see ContextFactory#call(ContextAction) */ public static Context getCurrentContext() { Object helper = VMBridge.instance.getThreadContextHelper(); return VMBridge.instance.getContext(helper); }
private InterfaceAdapter(ContextFactory cf, Class<?> cl) { this.proxyHelper = VMBridge.instance.getInterfaceProxyHelper( cf, new Class[] { cl }); }
private void init(Method method) { this.memberObject = method; this.argTypes = method.getParameterTypes(); this.vararg = VMBridge.instance.isVarArgs(method); }
/** * Exit a block of code requiring a Context. * * Calling <code>exit()</code> will remove the association between * the current thread and a Context if the prior call to * {@link ContextFactory#enterContext()} on this thread newly associated a * Context with this thread. Once the current thread no longer has an * associated Context, it cannot be used to execute JavaScript until it is * again associated with a Context. * @see ContextFactory#enterContext() */ public static void exit() { Object helper = VMBridge.instance.getThreadContextHelper(); Context cx = VMBridge.instance.getContext(helper); if (cx == null) { throw new IllegalStateException( "Calling Context.exit without previous Context.enter"); } if (cx.enterCount < 1) Kit.codeBug(); if (--cx.enterCount == 0) { VMBridge.instance.setContext(helper, null); cx.factory.onContextReleased(cx); } }
Object newInstance(Object[] args) { Constructor<?> ctor = ctor(); try { try { return ctor.newInstance(args); } catch (IllegalAccessException ex) { if (!VMBridge.instance.tryToMakeAccessible(ctor)) { throw Context.throwAsScriptRuntimeEx(ex); } } return ctor.newInstance(args); } catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); } }
if (loader == null) { ClassLoader threadLoader = VMBridge.instance.getCurrentThreadClassLoader(); if (threadLoader != null && Kit.testIfCanLoadRhinoClasses(threadLoader))
cache.cacheInterfaceAdapter(cl, adapter); return VMBridge.instance.newInterfaceProxy( adapter.proxyHelper, cf, adapter, function, topScope);
VMBridge.instance.getJavaIterator(cx, scope, obj); if (iterator != null) { scope = ScriptableObject.getTopLevelScope(scope);
private static void releaseContext(Object contextHelper, Context cx) { VMBridge.instance.setContext(contextHelper, null); try { cx.factory.onContextReleased(cx); } finally { cx.factory = null; } }
/** * Exit a block of code requiring a Context. * * Calling <code>exit()</code> will remove the association between * the current thread and a Context if the prior call to * {@link ContextFactory#enterContext()} on this thread newly associated a * Context with this thread. Once the current thread no longer has an * associated Context, it cannot be used to execute JavaScript until it is * again associated with a Context. * @see ContextFactory#enterContext() */ public static void exit() { Object helper = VMBridge.instance.getThreadContextHelper(); Context cx = VMBridge.instance.getContext(helper); if (cx == null) { throw new IllegalStateException( "Calling Context.exit without previous Context.enter"); } if (cx.enterCount < 1) Kit.codeBug(); if (--cx.enterCount == 0) { VMBridge.instance.setContext(helper, null); cx.factory.onContextReleased(cx); } }
Object newInstance(Object[] args) { Constructor ctor = ctor(); try { try { return ctor.newInstance(args); } catch (IllegalAccessException ex) { if (!VMBridge.instance.tryToMakeAccessible(ctor)) { throw Context.throwAsScriptRuntimeEx(ex); } } return ctor.newInstance(args); } catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); } }
if (loader == null) { ClassLoader threadLoader = VMBridge.instance.getCurrentThreadClassLoader(); if (threadLoader != null && Kit.testIfCanLoadRhinoClasses(threadLoader))
cache.cacheInterfaceAdapter(cl, adapter); return VMBridge.instance.newInterfaceProxy( adapter.proxyHelper, cf, adapter, object, topScope);
VMBridge.instance.getJavaIterator(cx, scope, obj); if (iterator != null) { scope = ScriptableObject.getTopLevelScope(scope);
private static Context prepareNewContext(ContextFactory factory, Object contextHelper) { Context cx = factory.makeContext(); if (cx.factory != null || cx.enterCount != 0) { throw new IllegalStateException("factory.makeContext() returned Context instance already associated with some thread"); } cx.factory = factory; factory.onContextCreated(cx); if (factory.isSealed() && !cx.isSealed()) { cx.seal(null); } VMBridge.instance.setContext(contextHelper, cx); return cx; }
/** * Exit a block of code requiring a Context. * * Calling <code>exit()</code> will remove the association between * the current thread and a Context if the prior call to * {@link ContextFactory#enterContext()} on this thread newly associated a * Context with this thread. Once the current thread no longer has an * associated Context, it cannot be used to execute JavaScript until it is * again associated with a Context. * @see ContextFactory#enterContext() */ public static void exit() { Object helper = VMBridge.instance.getThreadContextHelper(); Context cx = VMBridge.instance.getContext(helper); if (cx == null) { throw new IllegalStateException( "Calling Context.exit without previous Context.enter"); } if (cx.enterCount < 1) Kit.codeBug(); if (--cx.enterCount == 0) { VMBridge.instance.setContext(helper, null); cx.factory.onContextReleased(cx); } }
/** * Get the current Context. * * The current Context is per-thread; this method looks up * the Context associated with the current thread. <p> * * @return the Context associated with the current thread, or * null if no context is associated with the current * thread. * @see ContextFactory#enterContext() * @see ContextFactory#call(ContextAction) */ public static Context getCurrentContext() { Object helper = VMBridge.instance.getThreadContextHelper(); return VMBridge.instance.getContext(helper); }
private void init(Constructor<?> constructor) { this.memberObject = constructor; this.argTypes = constructor.getParameterTypes(); this.vararg = VMBridge.instance.isVarArgs(constructor); }
Object newInstance(Object[] args) { Constructor<?> ctor = ctor(); try { try { return ctor.newInstance(args); } catch (IllegalAccessException ex) { if (!VMBridge.instance.tryToMakeAccessible(ctor)) { throw Context.throwAsScriptRuntimeEx(ex); } } return ctor.newInstance(args); } catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); } }
private InterfaceAdapter(ContextFactory cf, Class<?> cl) { this.proxyHelper = VMBridge.instance.getInterfaceProxyHelper( cf, new Class[] { cl }); }