package sun.jvm.hotspot.utilities.soql.wrapper; import java.lang.reflect.Method; import java.util.Arrays; import jdk.nashorn.api.scripting.AbstractJSObject; public class JSObjectInstanceWrapper extends AbstractJSObject{ private final Object thisObj; private final Method[] methods; public JSObjectInstanceWrapper(Object thisObj){ this.thisObj = thisObj; this.methods = thisObj.getClass().getMethods(); } @Override public Object getMember(String name){ var method = Arrays.stream(methods) .filter(m -> m.getName().equals(name)) .findFirst() .get(); return new JSObjectMethodWrapper(thisObj, method); } @Override public boolean hasMember(String name){ return Arrays.stream(methods) .anyMatch(m -> m.getName().equals(name)); } }