Package org.mozilla.javascript
Class VMBridge
java.lang.Object
org.mozilla.javascript.VMBridge
- Direct Known Subclasses:
VMBridge_jdk18
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Context
getContext
(Object contextHelper) GetContext
instance associated with the current thread or null if none.protected abstract Object
getInterfaceProxyHelper
(ContextFactory cf, Class<?>[] interfaces) Create helper object to create later proxies implementing the specified interfaces later.protected abstract Object
Return a helper object to optimizeContext
access.protected abstract Object
newInterfaceProxy
(Object proxyHelper, ContextFactory cf, InterfaceAdapter adapter, Object target, Scriptable topScope) Create proxy object forInterfaceAdapter
.protected abstract void
setContext
(Object contextHelper, Context cx) AssociateContext
instance with the current thread or remove the current association ifcx
is null.protected abstract boolean
tryToMakeAccessible
(AccessibleObject accessible) In many JVMSs, public methods in private classes are not accessible by default (Sun Bug #4071593).
-
Constructor Details
-
VMBridge
public VMBridge()
-
-
Method Details
-
getThreadContextHelper
Return a helper object to optimizeContext
access.The runtime will pass the resulting helper object to the subsequent calls to
getContext(Object contextHelper)
andsetContext(Object contextHelper, Context cx)
methods. In this way the implementation can use the helper to cache information about current thread to makeContext
access faster. -
getContext
GetContext
instance associated with the current thread or null if none.- Parameters:
contextHelper
- The result ofgetThreadContextHelper()
called from the current thread.
-
setContext
AssociateContext
instance with the current thread or remove the current association ifcx
is null.- Parameters:
contextHelper
- The result ofgetThreadContextHelper()
called from the current thread.
-
tryToMakeAccessible
In many JVMSs, public methods in private classes are not accessible by default (Sun Bug #4071593). VMBridge instance should try to workaround that via, for example, calling method.setAccessible(true) when it is available. The implementation is responsible to catch all possible exceptions like SecurityException if the workaround is not available.- Returns:
- true if it was possible to make method accessible or false otherwise.
-
getInterfaceProxyHelper
Create helper object to create later proxies implementing the specified interfaces later. Under JDK 1.3 the implementation can look like:return java.lang.reflect.Proxy.getProxyClass(..., interfaces). getConstructor(new Class[] { java.lang.reflect.InvocationHandler.class });
- Parameters:
interfaces
- Array with one or more interface class objects.
-
newInterfaceProxy
protected abstract Object newInterfaceProxy(Object proxyHelper, ContextFactory cf, InterfaceAdapter adapter, Object target, Scriptable topScope) Create proxy object forInterfaceAdapter
. The proxy should callInterfaceAdapter.invoke(ContextFactory, Object, Scriptable, Object, Method, Object[])
as implementation of interface methods associated withproxyHelper
.Method
- Parameters:
proxyHelper
- The result of the previous call togetInterfaceProxyHelper(ContextFactory, Class[])
.
-