!jdk.internal.reflect.*,
!jdk.vm.ci.services
</bnd.importpackage>
- <graal.version>20.1.0</graal.version>
+ <graal.version>21.3.0</graal.version>
<asm.version>6.2.1</asm.version>
<oh.version>${project.version}</oh.version>
</properties>
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
- <version>62.1</version>
+ <version>69.1</version>
</dependency>
<!-- include as version required is older than OH provides -->
+++ /dev/null
-/**
- * Copyright (c) 2010-2021 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.automation.jsscripting;
-
-import com.oracle.truffle.js.runtime.java.adapter.JavaAdapterFactory;
-
-/**
- * Class utility to allow creation of 'extendable' classes with a classloader of the GraalJS bundle, rather than the
- * classloader of the file being extended.
- *
- * @author Jonathan Gilbert - Initial contribution
- */
-public class ClassExtender {
- private static ClassLoader classLoader = ClassExtender.class.getClassLoader();
-
- public static Object extend(String className) {
- try {
- return extend(Class.forName(className));
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Cannot find class " + className, e);
- }
- }
-
- public static Object extend(Class<?> clazz) {
- return JavaAdapterFactory.getAdapterClassFor(clazz, null, classLoader);
- }
-}
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.graalvm.polyglot.Context;
+import org.graalvm.polyglot.Engine;
import org.openhab.automation.jsscripting.internal.fs.DelegatingFileSystem;
import org.openhab.automation.jsscripting.internal.fs.PrefixedSeekableByteChannel;
import org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocable;
*/
public OpenhabGraalJSScriptEngine() {
super(null); // delegate depends on fields not yet initialised, so we cannot set it immediately
- delegate = GraalJSScriptEngine.create(null,
+ delegate = GraalJSScriptEngine.create(
+ Engine.newBuilder().allowExperimentalOptions(true).option("engine.WarnInterpreterOnly", "false")
+ .build(),
Context.newBuilder("js").allowExperimentalOptions(true).allowAllAccess(true)
.option("js.commonjs-require-cwd", MODULE_DIR).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
.hostClassLoader(getClass().getClassLoader())
.fileSystem(new DelegatingFileSystem(FileSystems.getDefault().provider()) {