You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2020/05/27 16:03:51 UTC
[ant] branch graal.js updated: graal.js also registers itself for
Javascript
This is an automated email from the ASF dual-hosted git repository.
bodewig pushed a commit to branch graal.js
in repository https://gitbox.apache.org/repos/asf/ant.git
The following commit(s) were added to refs/heads/graal.js by this push:
new 2379629 graal.js also registers itself for Javascript
2379629 is described below
commit 23796294cb765004f7300e36d0aaf284eed09bad
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Wed May 27 18:02:34 2020 +0200
graal.js also registers itself for Javascript
---
.../apache/tools/ant/util/optional/JavaxScriptRunner.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java b/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
index cf9c4e2..761e5c8 100644
--- a/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
+++ b/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
@@ -145,10 +145,6 @@ public class JavaxScriptRunner extends ScriptRunnerBase {
"Unable to create javax script engine for "
+ getLanguage());
}
- if (getLanguage().startsWith("graal.")) {
- engine.getBindings(ScriptContext.ENGINE_SCOPE)
- .put("polyglot.js.allowAllAccess", true);
- }
applyBindings(engine::put);
@@ -196,12 +192,22 @@ public class JavaxScriptRunner extends ScriptRunnerBase {
}
ScriptEngine result =
new ScriptEngineManager().getEngineByName(getLanguage());
+ maybeApplyGraalJsProperties(result);
if (result != null && getKeepEngine()) {
this.keptEngine = result;
}
return result;
}
+ private static final String DROP_GRAAL_SECURITY_RESTRICTIONS = "polyglot.js.allowAllAccess";
+
+ private void maybeApplyGraalJsProperties(final ScriptEngine engine) {
+ if (engine != null && engine.getClass().getName().contains("Graal")) {
+ engine.getBindings(ScriptContext.ENGINE_SCOPE)
+ .put(DROP_GRAAL_SECURITY_RESTRICTIONS, true);
+ }
+ }
+
/**
* Traverse a Throwable's cause(s) and return the BuildException
* most deeply nested into it - if any.