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
We are migrating to GraalJS as scripting engine behind the javax.script API in replacement of Nashorn. We were waiting for #631 and happy to see it finally implemented in 21.3.0.
In our case we need to execute multiple script blocks in isolation, but all have some common data/tools used. By doing this, we are hitting some strange issues. Find below the detailed data to reproduce the case.
Initialization script (INIT). We want BigDecimal and MathContext to be available in all the lines that will be executed. This script is executed in the ENGINE_SCOPE that will be the 'super-scope' for all our lines.
javax.script.ScriptException: org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (divide) on java.math.BigDecimal@12bfd80d failed due to: Multiple applicable overloads found for method name divide (candidates: [Method[public java.math.BigDecimal java.math.BigDecimal.divide(java.math.BigDecimal,java.math.MathContext)], Method[public java.math.BigDecimal java.math.BigDecimal.divide(java.math.BigDecimal,java.math.RoundingMode)]], arguments: [JavaObject[3 (java.math.BigDecimal)] (HostObject), DynamicObject<undefined>@b2c5e07 (Nullish)])
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.toScriptException(GraalJSScriptEngine.java:483)
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:460)
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.access$400(GraalJSScriptEngine.java:83)
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine$10.eval(GraalJSScriptEngine.java:628)
at java.scripting/javax.script.CompiledScript.eval(CompiledScript.java:89)
at ch.astorm.graaljs.ScopeTest.evaluate(ScopeTest.java:53)
at ch.astorm.graaljs.ScopeTest.testFailureDivision(ScopeTest.java:45)
Caused by: org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (divide) on java.math.BigDecimal@12bfd80d failed due to: Multiple applicable overloads found for method name divide (candidates: [Method[public java.math.BigDecimal java.math.BigDecimal.divide(java.math.BigDecimal,java.math.MathContext)], Method[public java.math.BigDecimal java.math.BigDecimal.divide(java.math.BigDecimal,java.math.RoundingMode)]], arguments: [JavaObject[3 (java.math.BigDecimal)] (HostObject), DynamicObject<undefined>@b2c5e07 (Nullish)])
at <js>.:program(script:3)
at org.graalvm.polyglot.Context.eval(Context.java:379)
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458)
... 23 more
Here is a small project that reproduces the case. Just type mvn clean package in graaljs-bug dir to see it.
The text was updated successfully, but these errors were encountered:
ctabin
changed the title
[JDK11][javax.script] TypeError with scoped Bindings
[21.3.0][JDK11][javax.script] TypeError with scoped Bindings
Oct 21, 2021
Hello,
We are migrating to GraalJS as scripting engine behind the
javax.script
API in replacement of Nashorn. We were waiting for #631 and happy to see it finally implemented in 21.3.0.In our case we need to execute multiple script blocks in isolation, but all have some common data/tools used. By doing this, we are hitting some strange issues. Find below the detailed data to reproduce the case.
Initialization script (
INIT
). We wantBigDecimal
andMathContext
to be available in all the lines that will be executed. This script is executed in theENGINE_SCOPE
that will be the 'super-scope' for all our lines.The ScriptEngine is initialized like this:
Here is the sample script used (
SCRIPT
):When the script is executed in the
ENGINE_SCOPE
, there is no problem:However, when an isolated scope is created, then an error is thrown
Here is a small project that reproduces the case. Just type
mvn clean package
ingraaljs-bug
dir to see it.The text was updated successfully, but these errors were encountered: