Re: Pass js array to a Java method pointer

2017-05-16 Thread Jim Laskey (Oracle)
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

Re: Pass js array to a Java method pointer

2017-05-16 Thread xu qingyi
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.

Re: Pass js array to a Java method pointer

2017-05-16 Thread Jim Laskey (Oracle)
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))")

Pass js array to a Java method pointer

2017-05-16 Thread qiyi
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) {