Skip to content

Commit

Permalink
add graaljs compatibility parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed May 8, 2019
1 parent e5b26d8 commit 284fd04
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions samples/src/main/java/org/bsc/java2ts/JSRun.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package org.bsc.java2ts;

import java.util.function.Predicate;

import javax.script.Bindings;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

Expand Down Expand Up @@ -46,6 +50,10 @@ public static void main(String[] args) throws Exception {
final ScriptEngineManager manager = new ScriptEngineManager();

final ScriptEngine service = manager.getEngineByName("graal.js");
final Bindings bindings = service.getBindings(ScriptContext.ENGINE_SCOPE);
// @see https://github.com/graalvm/graaljs/blob/master/docs/user/ScriptEngine.md
bindings.put("polyglot.js.allowHostAccess", true);
bindings.put("polyglot.js.allowHostClassLookup", (Predicate<String>) s -> true);

service.put( "$ARG", args );

Expand Down

0 comments on commit 284fd04

Please sign in to comment.