As discussed in https://github.com/oracle/graaljs/issues/414, you need to:
- expose
Math.class
and then access math.static.toRadians()
- enable HostAccess on the Context you are using
The working example thus is:
try (Context ctx = Context.newBuilder("js").allowHostAccess(HostAccess.ALL).build()) {
ctx.getBindings("js").putMember("math", Math.class);
ctx.eval("js", "print(math.static.toRadians(180));");
ctx.close();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…