On Apr 29, 3:09 am, [email protected] wrote:
> Are you sure that ImporterTopLevel has something which calls
> Context.initStandardObjects() in it's constructor? This seems the most
> likely cause.

Yes, that did the trick. For the record, the solution is

ImporterTopLevel scope = new ImporterTopLevel();
Context cx = Context.enter();
StringBuffer sb = new StringBuffer();
sb.append("function compute() {\n");
sb.append("    return Math.sin(42);\n");
sb.append("}\n");
cx.initStandardObjects(scope);
cx.evaluateString(scope, sb.toString(), "inline JavaScript", 0,
null);
Object result = ScriptableObject.callMethod(scope, "compute", new
Object[0]);
System.out.println("Result: " + result);

Thanks!
Holger
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to