Try 

cx.newArray(scope, 0)

instead. Constructing a NativeArray object directly won't work, 'cause it still 
needs to have its prototype set to the value of "Array.prototype" from your 
scope. newArray() will take care of all of that.

Attila.

On 2010.06.22., at 10:00, Raphael Pigulla wrote:

> Hello,
> 
> I'm trying to run JSLint using Rhino, but I've encountered a problem that has 
> somewhat stumped me. How can I create a 'real' array from Java? Here's what 
> I've been trying:
> 
>  Context cx = Context.enter();
>  Scriptable scope = cx.initStandardObjects();
>  String src = "function f(a) { return a instanceof Array; };";
> 
>  cx.evaluateString(scope, src, "<src>", 0, null);
> 
>  Function f = (Function) scope.get("f", scope);
>  Object[] fArgs = new Object[]{ new NativeArray(0) };
>  Object result = f.call(cx, scope, scope, fArgs);
> 
>  System.out.println(Context.toString(result));
>  Context.exit();
> 
> But result is false. What am I doing wrong?
> 
> P.S.: Since I don't want to mess with JSLint's source, it is essential that I 
> can create an object that passes the "instanceof" test.
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to