Introduction
JS7 enables execution of JS7 - GraalVM JavaScript Jobs and JS7 - GraalVM Python Jobs using the GraalVM Polyglot interface.
To allow full control of the run-time environment, security, and guest language behavior, JS7 provides a mechanism to configure GraalVM run-time options.
- Options govern how guest languages (GraalVM JavaScript/Python) interact with the host JVM, which features are permitted, and how language-specific behavior is customized.
- Some options affect permissions and host access, while others control language-specific run-time behavior.
Configuring GraalVM Options
GraalVM options can be configured from a single argument, named according to the pattern: js7_options.graalvm.<language>
Examples:
js7_options.graalvm.js- GraalVM JavaScript run-time configuration
js7_options.graalvm.python- GraalVM Python run-time configuration
The argument can be provided in a number of ways:
- As a file reference (toFile)
- As a JSON string
- Using various configuration sources, such as Job Resources, Order Variables, Job Arguments and Node arguments.
Types of GraalVM Options
There are two categories of configurable options:
Polyglot Access Methods (Language-Independent)
The options control access permissions between the host JVM and guest languages.
See GraalVM documentation:
JS7 exposes the following GraalVM Context.Builder methods as configuration options.
Each option is named following the pattern: js7.polyglot.<Context.Builder method name>
| JS7 Option Name | Default | Corresponding Context.Builder Method | Method Description (GraalVM) | JS7 Behavior |
|---|---|---|---|---|
| true | allowCreateProcess(boolean enabled) | If true, allows guest language to execute external processes. | |
| true | allowCreateThread(boolean enabled) | If true, allows guest languages to create new threads. | |
| true | allowEnvironmentAccess(EnvironmentAccess accessPolicy) | Allow environment access using the provided policy. |
|
| true | allowExperimentalOptions(boolean enabled) | Allow experimental options to be used for language options. | |
| true | allowHostClassLookup(Predicate<String> classFilter) | Sets a filter that specifies the Java host classes that can be looked up by the guest application. |
Instead of boolean
|
| true |
| Configures guest language access to host IO. If | |
| true |
| Configures guest language access to host IO. If | |
js7.polyglot.allowNativeAccess | true | allowNativeAccess(boolean enabled) | Allows guest languages to access the native interface. | |
js7.polyglot.allowPolyglotAccess | true | allowPolyglotAccess(PolyglotAccess accessPolicy) | Allow polyglot access using the provided policy. |
|
Language-specific Options
The options are specific to a particular guest language and control run-time features unique to the language.
GraalVM Python
For available GraalVM Python content options, see GraalPy Context Options
Note: The options are used via the Polyglot Context in JS7, and their behavior may vary.
Example js7_options.graalvm.python:
{
"options": {
"python.PythonPath": "/opt/js7/python-libs:/home/js7user/python"
}
}
- The option specifies that the Python run-time will search for modules in specified directories.
- Path entries are separated by
:on Unix-like systems and by;on Windows.
GraalVM JavaScript
GraalVM JavaScript content options are not as clearly documented from GraalPy.
Some links:
- https://www.graalvm.org/dev/reference-manual/js/Modules/
- https://www.graalvm.org/dev/reference-manual/js/Options/
Example js7_options.graalvm.js:
{
"options": {
"js.commonjs-require": true,
"js.commonjs-require-cwd": "/opt/js7/javascript-libs"
}
}
Note: Experimental options may require allowExperimentalOptions(true).