org.mozilla.javascript
Class VMBridge
java.lang.Object
org.mozilla.javascript.VMBridge
public abstract class VMBridge
extends java.lang.Object
getContext
protected abstract Context getContext(Object contextHelper)
Get
Context
instance associated with the current thread
or null if none.
contextHelper
- The result of getThreadContextHelper()
called from the current thread.
getCurrentThreadClassLoader
protected abstract ClassLoader getCurrentThreadClassLoader()
Return the ClassLoader instance associated with the current thread.
getInterfaceProxyHelper
protected Object getInterfaceProxyHelper(ContextFactory cf,
Class[] interfaces)
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 });
interfaces
- Array with one or more interface class objects.
getThreadContextHelper
protected abstract Object getThreadContextHelper()
Return a helper object to optimize
Context
access.
The runtime will pass the resulting helper object to the subsequent
calls to
getContext(Object contextHelper)
and
setContext(Object contextHelper, Context cx)
methods.
In this way the implementation can use the helper to cache
information about current thread to make
Context
access faster.
newInterfaceProxy
protected Object newInterfaceProxy(Object proxyHelper,
ContextFactory cf,
InterfaceAdapter adapter,
Object target,
Scriptable topScope)
Create proxy object for
InterfaceAdapter
. The proxy should call
InterfaceAdapter.invoke(ContextFactory cf,
Object target,
Scriptable topScope,
Method method,
Object[] args)
as implementation of interface methods associated with
proxyHelper.
proxyHelper
- The result of the previous call to
.
setContext
protected abstract void setContext(Object contextHelper,
Context cx)
Associate
Context
instance with the current thread or remove
the current association if
cx is null.
contextHelper
- The result of getThreadContextHelper()
called from the current thread.
tryToMakeAccessible
protected abstract boolean tryToMakeAccessible(Object accessibleObject)
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.
- true if it was possible to make method accessible
or false otherwise.