graal
graal copied to clipboard
"new java.util.ArrayList(['item1','item2'])" raises error
Describe the issue
We are replacing Nashorn with Graal, found code new java.util.ArrayList(['item1','item2'])
works in Nashorn but raises error in Graal. I am wondering whether it is an issue in Graal.
Steps to reproduce the issue
Here is some code Context.Builder graalContextBuilder = Context.newBuilder() .allowExperimentalOptions(true) .option("js.nashorn-compat", "true")// make Nashorn external features work e.g. print function .allowHostAccess(HostAccess.ALL) .allowHostClassLookup((s) -> true); GraalJSScriptEngine grallEngine = GraalJSScriptEngine.create(null, graalContextBuilder); grallEngine.eval("new java.util.ArrayList(['item1','item2'])");
which throws exception
javax.script.ScriptException: java.lang.UnsupportedOperationException: Unsupported operation identifier 'toArray' and object '[object Array]'(language: JavaScript, type: Array). Identifier is not executable or instantiable.
GraalVM and environment:
- GraalVM version: 22.2.0
- JDK major version: OpenJDK 11.0.14
- OS: Windows 10
- Architecture: AMD64
Hi, Thank you for reporting this, we will take a look into it and get back to you
@oubidar-Abderrahim Understand being assigned to this task doesn't necessarily mean it will get looked at, but I'm also affected by this bug. Once you've had a chance to review, would it be possible to indicate whether it's likely to be a small or large effort to fix? That might help me in deciding whether to try and wait for a fix or not.
If this issue is still relevant in the latest GraalVM versions, please create a new issue for it and follow the template provided. Thank you