Top Description Fields Constructors Methods
org.apache.tools.ant.util.optional

public Class JavaxScriptRunner

extends ScriptRunnerBase
Class Inheritance
Imports
java.util.Arrays, .List, .Map, .Objects, java.util.function.BiConsumer, java.util.stream.Collectors, javax.script.Bindings, javax.script.Compilable, javax.script.CompiledScript, javax.script.ScriptContext, javax.script.ScriptEngine, javax.script.ScriptEngineManager, javax.script.SimpleBindings, org.apache.tools.ant.BuildException, .MagicNames, .Project, org.apache.tools.ant.util.JavaEnvUtils, .ScriptRunnerBase

This class is used to run scripts using JSR 223.
Since
Ant 1.7.0

Field Summary

Modifier and TypeField and Description
private javax.script.CompiledScript
private static final String
private static final String
private static final List<String>
private javax.script.ScriptEngine

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
private javax.script.ScriptEngine
public Object

Returns:

the result of the evaluation
evaluateScript
(String
the name that will be passed to the scripting engine for this script execution.
execName
)

Implements abstract org.apache.tools.ant.util.ScriptRunnerBase.evaluateScript.

Do the work to eval the script.
public void
executeScript(String
the name that will be passed to the scripting engine for this script execution.
execName
)

Implements abstract org.apache.tools.ant.util.ScriptRunnerBase.executeScript.

Do the work to run the script.
public String

Returns:

"javax"
getManagerName
()

Implements abstract org.apache.tools.ant.util.ScriptRunnerBase.getManagerName.

Get the name of the manager prefix.
private boolean
private void
maybeApplyGraalJsProperties(final javax.script.ScriptEngine engine)

private void
public boolean
supportsLanguage()

Implements abstract org.apache.tools.ant.util.ScriptRunnerBase.supportsLanguage.

Check if a script engine can be created for this language..
private static BuildException
unwrap(Throwable t)

Traverse a Throwable's cause(s) and return the BuildException most deeply nested into it - if any.

Inherited from org.apache.tools.ant.util.ScriptRunnerBase:
addBeanaddBeansaddTextbindToComponentbindToComponentMinimumcheckLanguageclearScriptgetBeansgetCompiledgetKeepEnginegetLanguagegetProjectgetScriptgetScriptClassLoaderloadResourceloadResourcesreplaceContextLoaderrestoreContextLoadersetCompiledsetEncodingsetKeepEnginesetLanguagesetProjectsetScriptClassLoadersetSrc

Field Detail

compiledScriptback to summary
private javax.script.CompiledScript compiledScript
DROP_GRAAL_SECURITY_RESTRICTIONSback to summary
private static final String DROP_GRAAL_SECURITY_RESTRICTIONS
ENABLE_NASHORN_COMPAT_IN_GRAALback to summary
private static final String ENABLE_NASHORN_COMPAT_IN_GRAAL
JS_LANGUAGESback to summary
private static final List<String> JS_LANGUAGES
keptEngineback to summary
private javax.script.ScriptEngine keptEngine

Constructor Detail

JavaxScriptRunnerback to summary
public JavaxScriptRunner()

Method Detail

applyBindingsback to summary
private void applyBindings(BiConsumer<String, Object> target)
createEngineback to summary
private javax.script.ScriptEngine createEngine()
evaluateScriptback to summary
public Object evaluateScript(String execName) throws BuildException

Implements abstract org.apache.tools.ant.util.ScriptRunnerBase.evaluateScript.

Do the work to eval the script.

Parameters
execName:String

the name that will be passed to the scripting engine for this script execution.

Returns:Object

the result of the evaluation

Exceptions
BuildException:
if something goes wrong executing the script.
executeScriptback to summary
public void executeScript(String execName) throws BuildException

Implements abstract org.apache.tools.ant.util.ScriptRunnerBase.executeScript.

Do the work to run the script.

Parameters
execName:String

the name that will be passed to the scripting engine for this script execution.

Annotations
@Override
Exceptions
BuildException:
if something goes wrong executing the script.
getManagerNameback to summary
public String getManagerName()

Implements abstract org.apache.tools.ant.util.ScriptRunnerBase.getManagerName.

Get the name of the manager prefix.

Returns:String

"javax"

Annotations
@Override
languageIsJavaScriptback to summary
private boolean languageIsJavaScript()
maybeApplyGraalJsPropertiesback to summary
private void maybeApplyGraalJsProperties(final javax.script.ScriptEngine engine)
maybeEnableNashornCompatibilityback to summary
private void maybeEnableNashornCompatibility()
supportsLanguageback to summary
public boolean supportsLanguage()

Implements abstract org.apache.tools.ant.util.ScriptRunnerBase.supportsLanguage.

Doc from org.apache.tools.ant.util.ScriptRunnerBase.supportsLanguage.

Check if a script engine can be created for this language..

Returns:boolean

true if a script engine can be created, false otherwise.

Annotations
@Override
unwrapback to summary
private static BuildException unwrap(Throwable t)

Traverse a Throwable's cause(s) and return the BuildException most deeply nested into it - if any.