Skip to content

Commit 09582e6

Browse files
wirthigilles-duboscq
authored andcommitted
update documentation
1 parent 225d38a commit 09582e6

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

docs/user/NashornMigrationGuide.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ This is the case for Nashorn-specific extensions that GraalVM JavaScript does no
3535
Note that you have to enable [experimental options](Options.md#stable-and-experimental-options) to use this flag.
3636
Further note that setting this flag defeats the [secure by default](#secure-by-default) approach of GraalVM JavaScript in some cases, e.g., when operating on a legacy `ScriptEngine`.
3737

38+
When you use the Nashorn compatibility mode, by default, ECMAScript 5 is set as compatibility level.
39+
You can specify a different ECMAScript version using the `js.ecmascript-version` flag; note that this might conflict with full Nashorn compatibilty.
40+
A code example how to set the flag is given near the end of this section.
41+
3842
The `js.nashorn-compat` option can be set:
3943
1. by using a command line option:
4044
```shell
@@ -55,7 +59,7 @@ try (Context context = Context.newBuilder().allowExperimentalOptions(true).optio
5559
java -Dpolyglot.js.nashorn-compat=true MyApplication
5660
```
5761

58-
Functionality only available under this flag includes:
62+
Functionality only available under the `nashorn-compat` flag includes:
5963
* `Java.isJavaFunction`, `Java.isJavaMethod`, `Java.isScriptObject`, `Java.isScriptFunction`
6064
* `new Interface|AbstractClass(fn|obj)`
6165
* `JavaImporter`
@@ -64,6 +68,13 @@ Functionality only available under this flag includes:
6468
* `load("nashorn:parser.js")`, `load("nashorn:mozilla_compat.js")`
6569
* `exit`, `quit`
6670

71+
The `js.ecmascript-version` option can be set in similar fashion.
72+
As this is a supported option, there is no need to provide the `experimental-options` flag just for setting the `ecmascript-version`:
73+
1. by using a command line option:
74+
```shell
75+
js --js.ecmascript-version=2020
76+
```
77+
6778
## Nashorn Syntax Extensions
6879

6980
[Nashorn syntax extensions](https://wiki.openjdk.java.net/display/Nashorn/Nashorn+extensions) can be enabled using the `js.syntax-extensions` experimental option.

docs/user/Options.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The following options are currently available:
3939
* `--js.annex-b`: enable ECMAScript Annex B web compatibility features. Boolean value, default is `true`.
4040
* `--js.array-sort-inherited`: define whether `Array.protoype.sort` should sort inherited keys (implementation-defined behavior). Boolean value, default is `true`.
4141
* `--js.atomics`: enable *ES2017 Atomics*. Boolean value, default is `true`.
42-
* `--js.ecmascript-version`: emulate a specific ECMAScript version. Integer value (`5`-`9`), default is the latest version.
42+
* `--js.ecmascript-version`: emulate a specific ECMAScript version. Integer value (`5`-`13`, or `2015`-`2022`), default is the latest stable version.
4343
* `--js.foreign-object-prototype`: provide JavaScript's default prototype to foreign objects that mimic JavaScript's own types (foreign Arrays, Objects and Functions). Boolean value, default is `false`.
4444
* `--js.intl-402`: enable ECMAScript Internationalization API. Boolean value, default is `false`.
4545
* `--js.regexp-static-result`: provide static `RegExp` properties containing the results of the last successful match, e.g., `RegExp.$1` (legacy). Boolean value, default is `true`.
@@ -72,8 +72,7 @@ See [ScriptEngine Implementation](ScriptEngine.md) on how to use experimental op
7272

7373
This option provides compatibility to a specific version of the ECMAScript specification.
7474
It expects an integer value, where both the counting version numbers (`5` to `11`) and the publication years (starting from `2015`) are supported.
75-
The default in the development version of GraalVM is the current draft of the specification, currently the [`ECMAScript 2021 draft specification`](https://tc39.es/ecma262/).
76-
Thus, starting with GraalVM 21.0.0, the default will move to the draft ECMAScript 2021 specification.
75+
The default in the development version of GraalVM is the [`ECMAScript 2021 specification`](https://tc39.es/ecma262/).
7776
GraalVM JavaScript implements some features of the future draft specification and of open proposals, if you explicitly select that version and/or enable specific experimental flags.
7877
For production settings, it is recommended to set the `ecmascript-version` to an existing, finalized version of the specification.
7978

@@ -84,10 +83,12 @@ Available versions are:
8483
* `8` or `2017` for ECMAScript 2017
8584
* `9` or `2018` for ECMAScript 2018
8685
* `10` or `2019` for ECMAScript 2019
87-
* `11` or `2020` for ECMAScript 2020 (latest finalized version of the specification)
88-
* `12` or `2021` for ECMAScript 2021 (**default**, currently in draft stage)
86+
* `11` or `2020` for ECMAScript 2020
87+
* `12` or `2021` for ECMAScript 2021 (**default**, latest finalized version of the specification)
8988
* `13` or `2022` for ECMAScript 2022 (future changes and proposals)
9089

90+
As of GraalVM 21.2, the flag can also be set to `latest` or `staging`, to use the latest stable version (which is the default), or the staging version including experimental functionality under development.
91+
9192
## intl-402
9293

9394
This option enables ECMAScript's [Internationalization API](https://tc39.github.io/ecma402/).

docs/user/ScriptEngine.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ These options are:
2222
* `polyglot.js.allowHostClassLookup <boolean or Predicate<String>>`
2323
* `polyglot.js.allowHostClassLoading <boolean>`
2424
* `polyglot.js.allowAllAccess <boolean>`
25+
* `polyglot.js.nashorn-compat <boolean>`
26+
* `polyglot.js.ecmascript-version <String>`
2527

2628
These options control the sandboxing rules applied to evaluated JavaScript code and are set to `false` by default, unless the application was started in the Nashorn compatibility mode (`--js.nashorn-compat=true`).
2729

0 commit comments

Comments
 (0)