< prev index next >
src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFunction.java
Print this page
*** 33,42 ****
--- 33,43 ----
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.util.List;
import jdk.dynalink.linker.support.Lookup;
import jdk.nashorn.api.scripting.JSObject;
+ import jdk.nashorn.api.scripting.ScriptObjectMirror;
import jdk.nashorn.internal.objects.annotations.Attribute;
import jdk.nashorn.internal.objects.annotations.Constructor;
import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.parser.Parser;
*** 99,110 ****
checkCallable(self);
final Object[] args = toApplyArgs(array);
if (self instanceof ScriptFunction) {
return ScriptRuntime.apply((ScriptFunction)self, thiz, args);
! } else if (self instanceof JSObject) {
return ((JSObject)self).call(thiz, args);
}
throw new AssertionError("Should not reach here");
}
/**
--- 100,116 ----
checkCallable(self);
final Object[] args = toApplyArgs(array);
if (self instanceof ScriptFunction) {
return ScriptRuntime.apply((ScriptFunction)self, thiz, args);
! } else if (self instanceof ScriptObjectMirror) {
return ((JSObject)self).call(thiz, args);
+ } else if (self instanceof JSObject) {
+ final Global global = Global.instance();
+ final Object result = ((JSObject) self).call(ScriptObjectMirror.wrap(thiz, global),
+ ScriptObjectMirror.wrapArray(args, global));
+ return ScriptObjectMirror.unwrap(result, global);
}
throw new AssertionError("Should not reach here");
}
/**
< prev index next >