Closed tabatintores closed 3 years ago
Hello there, This has been suggested several times, and they will look for a solution for this as the current JavaScript engine the expansion is using is not supported in Java anymore.
Would be great if you open the issue in the correct repository next time 👍
We're doing research on this in relation to PAPI 3. Look forward to a new engine, with es6 support in the future.
Simple fix(might be temporary fix) is to add this to jvm args: -Dnashorn.args=--language=es6
. This works on Java 11 not entirely sure about other versions though
Edit: This works on Java 8, however, there is selective support(during my testing lambdas didn't work) for es6 in java 8.
This can be done without specifying jvm arguments too:
import javax.script.ScriptEngine;
import javax.script.ScriptException;
import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
public class NashornFactory {
public static void main(String[] args) throws ScriptException {
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
ScriptEngine engine = factory.getScriptEngine("--language=es6");
engine.eval("const a = 100");
}
}
Reference: https://developer.oracle.com/databases/nashorn-javascript-part2.html
New version that darbyjack linked has support for quick_js.
The current expansion JavaScript supports only ES5. Can you add the ES6 support to the expansion?