Others are more expert than I but I believe the difference is that f1/f2
invokes are using hard Java Objects and f3/f4 invokes are using MethodHandles
with generic arguments.
> On May 16, 2017, at 3:36 PM, xu qingyi wrote:
>
> thx, Jim, I hava tried your solution and it works. but it need
thx, Jim, I hava tried your solution and it works. but it needs to invoke
java method so it's more complex. After all, what's the different between
f1, f2 and f4.
2017年5月17日 上午2:28,"Jim Laskey (Oracle)" 写道:
It could have inferred that you meant to pass in a single element object array.
It could have inferred that you meant to pass in a single element object array.
Nashorn needs a bit more to determine that you wanted to convert to an java
object array.
System.out.println(nashorn.eval("var ObjectArray =
Java.type('java.lang.Object[]'); f4(Java.to([1,2], ObjectArray))")
Hi, all, I'am trying to add a function to nashorn engine's bindings, and
these methods I have tried:
public class MyFunction implements Function {
@Override
public Object apply(Object[] objects) {
return Arrays.toString(objects);
}
public Object f2(Object[] objects) {