]> git.basschouten.com Git - openhab-addons.git/commitdiff
[jsscripting] Upgrade to ECMAScript 2022 & Dependency improvements (#14093)
authorFlorian Hotze <florianh_dev@icloud.com>
Fri, 30 Dec 2022 22:04:43 +0000 (23:04 +0100)
committerGitHub <noreply@github.com>
Fri, 30 Dec 2022 22:04:43 +0000 (23:04 +0100)
* [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 https://github.com/oracle/graaljs/blob/685e5873af80a59636b697c949a172d8a7d694c3/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>
bundles/org.openhab.automation.jsscripting/pom.xml
bundles/org.openhab.automation.jsscripting/src/main/java/org/openhab/automation/jsscripting/internal/OpenhabGraalJSScriptEngine.java

index a2ed5b9f1bfe9e48d2118b18ffbc659f90603ec2..79c4fe899491e6fa5c64c51e4e9cbae9dc8ed72d 100644 (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>
       <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>
       <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>
index b541819df849d3ef3d010c5064be65653286afd1..7c1c8704408fc35fc3793f487d900b39ed3dc709 100644 (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