You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After updating the lib version my application start to throw the exception bellow k.equals is not a function.
Below I provide a small way to reproduce the error.
Changing the comment dependencies back, the code works as expected.
There is any document that explicit any regressions on this update or this is a bug?
I have hundreds of different files that will need fixed if I want to upgrade.
Code:
import org.graalvm.polyglot.Context;
public class Main {
public static void main(String[] args) {
Context context = Context.newBuilder()
.allowExperimentalOptions(true)
.option("js.nashorn-compat", "true")
.option("js.ecmascript-version", "2020")
.allowAllAccess(true)
.build();
var script =
"""
var namesList = java.util.List.of("test","test1");
namesList.stream()
.findFirst()
.map(s => java.util.stream.Stream.of(s.split(' '))
.anyMatch(k => k.equals('test'))
)
""";
Object contextEval = context.eval("js", script);
System.out.println(contextEval.toString());
}
}
~/.sdkman/candidates/java/21.0.3-tem/bin/java -javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=56879:/Applications/IntelliJ IDEA CE.app/Contents/bin -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath ~/graalvm/target/classes:~/.m2/repository/org/graalvm/polyglot/polyglot/24.1.2/polyglot-24.1.2.jar:~/.m2/repository/org/graalvm/sdk/collections/24.1.2/collections-24.1.2.jar:~/.m2/repository/org/graalvm/sdk/nativeimage/24.1.2/nativeimage-24.1.2.jar:~/.m2/repository/org/graalvm/sdk/word/24.1.2/word-24.1.2.jar:~/.m2/repository/org/graalvm/js/js-language/24.1.2/js-language-24.1.2.jar:~/.m2/repository/org/graalvm/regex/regex/24.1.2/regex-24.1.2.jar:~/.m2/repository/org/graalvm/truffle/truffle-api/24.1.2/truffle-api-24.1.2.jar:~/.m2/repository/org/graalvm/shadowed/icu4j/24.1.2/icu4j-24.1.2.jar:~/.m2/repository/org/graalvm/truffle/truffle-runtime/24.1.2/truffle-runtime-24.1.2.jar:~/.m2/repository/org/graalvm/sdk/jniutils/24.1.2/jniutils-24.1.2.jar:~/.m2/repository/org/graalvm/truffle/truffle-compiler/24.1.2/truffle-compiler-24.1.2.jar Main
[To redirect Truffle log output to a file use one of the following options:
* '--log.file=<path>' if the option is passed using a guest language launcher.
* '-Dpolyglot.log.file=<path>' if the option is passed using the host Java launcher.
* Configure logging using the polyglot embedding API.]
[engine] WARNING: The polyglot engine uses a fallback runtime that does not support runtime compilation to native code.
Execution without runtime compilation will negatively impact the guest application performance.
The following cause was found: JVMCI is not enabled for this JVM. Enable JVMCI using -XX:+EnableJVMCI.
For more information see: https://www.graalvm.org/latest/reference-manual/embed-languages/#runtime-optimization-support.
To disable this warning use the '--engine.WarnInterpreterOnly=false' option or the '-Dpolyglot.engine.WarnInterpreterOnly=false' system property.
Exception in thread "main" TypeError: k.equals is not a function
at <js> :=>(Unnamed:6:154-169)
at com.oracle.truffle.polyglot.PolyglotFunctionProxyHandler.invoke(PolyglotFunctionProxyHandler.java:151)
at jdk.proxy1/jdk.proxy1.$Proxy21.test(Unknown Source)
at java.base/java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
at java.base/java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:397)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:632)
at <js> :=>(Unnamed:5-6:94-170)
at com.oracle.truffle.polyglot.PolyglotFunction.apply(PolyglotFunction.java:66)
at java.base/java.util.Optional.map(Optional.java:260)
at <js> :program(Unnamed:3-7:52-172)
at org.graalvm.polyglot.Context.eval(Context.java:428)
at Main.main(Main.java:23)
Process finished with exit code 1
The text was updated successfully, but these errors were encountered:
The root of the problem is that there are two overrides of Stream.of: one that takes Object parameter and one that takes Object.... GraalVM 20.1.x prefers the second override while more recent versions prefer the first override.
Honestly, the selection of the right override is a bit tricky even in Java in this case. So, it is error-prone to depend on particular selection when this method is invoked using JavaScript-Java interoperability. I would suggest using an explicit selection of the override (which is possible in recent versions of graal-js). For example, java.util.stream.Stream['of(java.lang.Object[])'](s.split(' ')) in your case.
After updating the lib version my application start to throw the exception bellow
k.equals is not a function
.Below I provide a small way to reproduce the error.
Changing the comment dependencies back, the code works as expected.
There is any document that explicit any regressions on this update or this is a bug?
I have hundreds of different files that will need fixed if I want to upgrade.
Code:
pom.xml
stacktrace:
The text was updated successfully, but these errors were encountered: