package sun.jvm.hotspot.utilities.soql.wrapper; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import jdk.nashorn.api.scripting.AbstractJSObject; public class JSObjectMethodWrapper extends AbstractJSObject{ private final Object receiver; private final Method method; public JSObjectMethodWrapper(Object receiver, Method method){ this.receiver = receiver; this.method = method; } /** * Return result of this method object. */ @Override public Object call(Object thiz, Object... args){ Object result; try{ result = method.invoke(receiver, args); } catch(IllegalAccessException | InvocationTargetException e){ throw new RuntimeException(e); } return new JSObjectInstanceWrapper(result); } @Override public boolean isFunction(){ return true; } }