[jsscripting] Upgrade to ECMAScript 2022 & Dependency improvements (#14093)

* [jsscripting] Remove asm from dependencies in pom

GraalJS >= 20.3.0 doesn't require org.ow2.asm as compile dependency anymore, see https://mvnrepository.com/artifact/org.graalvm.js/js/20.3.0.

* [jsscripting] Remove dependency org.graalvm.js/js-launcher as it is not required

js-launcher is GraalVM's JavaScript command line interpreter and not required in the addon.
See https://www.graalvm.org/22.1/reference-manual/js/RunOnJDK/.

* [jsscripting] Add missing com.ibm.icu dependency

GraalJS changelog says that it is not required for GraalJS >= 22.0.0 (see 685e5873af/CHANGELOG.md (version-2200)).
But GraalJS 22.3.0 attempts to load classes from it during runtime.

* [jsscripting] Update GraalJS engine options

Compat, as its additional functionality is not used by openhab-js and user code is not expected to use it.

* [jsscripting] Remove com.ibm.icu/icu4j dependency
* [jsscripting] Don't disable Nashorn compat mode as openhab-js requires it for accessors

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This commit is contained in:
Florian Hotze 2022-12-30 23:04:43 +01:00 committed by GitHub
parent 6e6bd3701c
commit 931f004ab8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 39 deletions

View File

@ -22,8 +22,7 @@
!jdk.internal.reflect.*,
!jdk.vm.ci.services
</bnd.importpackage>
<graal.version>22.0.0.2</graal.version> <!-- DO NOT UPGRADE: 22.0.0.2 is the latest version working on armv7l / OpenJDK 11.0.16 -->
<asm.version>6.2.1</asm.version>
<graal.version>22.0.0.2</graal.version> <!-- DO NOT UPGRADE: 22.0.0.2 is the latest version working on armv7l / OpenJDK 11.0.16 & armv7l / Zulu 17.0.5+8 -->
<oh.version>${project.version}</oh.version>
<ohjs.version>openhab@3.1.2</ohjs.version>
</properties>
@ -122,11 +121,6 @@
<artifactId>js-scriptengine</artifactId>
<version>${graal.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-launcher</artifactId>
<version>${graal.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
@ -142,33 +136,7 @@
<artifactId>js</artifactId>
<version>${graal.version}</version>
</dependency>
<!-- com.ibm.icu.icu4j/69.1 is not required on GraalJS >= 22.0.0 as it moved to org.graalvm.truffle -->
<!-- include as version required is older than OH provides -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-analysis</artifactId>
<version>${asm.version}</version>
</dependency>
<!-- GraalJS changelog says that com.ibm.icu/icu4j is not required for GraalJS >= 22.0.0 as it moved to org.graalvm.truffle;
but GraalJS >= 22.2.0 requires it, so we'll need to add it when we upgrade -->
</dependencies>
</project>

View File

@ -113,10 +113,12 @@ public class OpenhabGraalJSScriptEngine
.build(),
Context.newBuilder("js").allowExperimentalOptions(true).allowAllAccess(true)
.allowHostAccess(HOST_ACCESS).option("js.commonjs-require-cwd", JSDependencyTracker.LIB_PATH)
.option("js.nashorn-compat", "true") // to ease migration
.option("js.ecmascript-version", "2021") // nashorn compat will enforce es5 compatibility, we
// want ecma2021
.option("js.commonjs-require", "true") // enable CommonJS module support
.option("js.nashorn-compat", "true") // Enable Nashorn compat mode as openhab-js relies on
// accessors, see
// https://github.com/oracle/graaljs/blob/master/docs/user/NashornMigrationGuide.md#accessors
.option("js.ecmascript-version", "2022") // If Nashorn compat is enabled, it will enforce ES5
// compatibility, we want ECMA2022
.option("js.commonjs-require", "true") // Enable CommonJS module support
.hostClassLoader(getClass().getClassLoader())
.fileSystem(new DelegatingFileSystem(FileSystems.getDefault().provider()) {
@Override