graal.js fails when re-running js function with exception

Created on 27 May 2019  路  4Comments  路  Source: oracle/graal

(spoiler): I have a github repo that's minimized to demonstrate this issue with the least possible code: https://github.com/gzoller/GraalBoom

I'm using the Invoker interface on Oracle JVM with graal.js. (I've also tried the Context interface w/same result).

I have a Java class with a Map data member that I've converted to a ProxyObject. I want to access this member in JS after passing in the object to a JS function.

My github code shows how I'm creating/passing these objects. I'm using sbt to run my test.

If I fire up sbt and type 'test', the very first run works great--expected result. But each subsequent run in the same sbt session produces the exception below. Here's what I notice: graal is looking for something called "getField" in my ProxyObject, but the ProxyObject interface specifies no such member, so...Boom!

If I completely exit sbt and re-enter/re-run, the first time run works again, then the same exception.

[info] - Does it work *** FAILED *** [info] javax.script.ScriptException: org.graalvm.polyglot.PolyglotException: java.lang.IllegalStateException: java.lang.IllegalAccessException: no such field: com.test.Options.hash/com.test.MapProxyObject/getField [info] at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.invoke(GraalJSScriptEngine.java:402) [info] at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.invokeFunction(GraalJSScriptEngine.java:390) [info] at com.test.GraalBoom.jsRun(GraalBoom.scala:17) [info] at com.test.TestMe.$anonfun$new$1(TestMe.scala:12) [info] at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85) [info] at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83) [info] at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104) [info] at org.scalatest.Transformer.apply(Transformer.scala:22) [info] at org.scalatest.Transformer.apply(Transformer.scala:20) [info] at org.scalatest.FunSpecLike$$anon$1.apply(FunSpecLike.scala:455) [info] ... [info] Cause: org.graalvm.polyglot.PolyglotException: java.lang.IllegalStateException: java.lang.IllegalAccessException: no such field: com.test.Options.hash/com.test.MapProxyObject/getField [info] at com.oracle.truffle.polyglot.HostFieldDesc$MHImpl.makeGetMethodHandle(HostFieldDesc.java:200) [info] at com.oracle.truffle.polyglot.HostFieldDesc$MHImpl.get(HostFieldDesc.java:156) [info] at com.oracle.truffle.polyglot.HostObject$ReadFieldNode.doCached(HostObject.java:1151) [info] at com.oracle.truffle.polyglot.HostObjectFactory$ReadFieldNodeGen.executeAndSpecialize(HostObjectFactory.java:1272) [info] at com.oracle.truffle.polyglot.HostObjectFactory$ReadFieldNodeGen.execute(HostObjectFactory.java:1237) [info] at com.oracle.truffle.polyglot.HostObject.readMember(HostObject.java:239) [info] at com.oracle.truffle.polyglot.HostObjectGen$InteropLibraryExports$Cached.readMemberNode_AndSpecialize(HostObjectGen.java:1221) [info] at com.oracle.truffle.polyglot.HostObjectGen$InteropLibraryExports$Cached.readMember(HostObjectGen.java:1199) [info] at com.oracle.truffle.api.interop.InteropLibraryGen$CachedDispatch.readMember(InteropLibraryGen.java:2983) [info] at com.oracle.truffle.js.nodes.access.PropertyGetNode$ForeignPropertyGetNode.foreignGet(PropertyGetNode.java:913) [info] ... [info] - Does it work 2 *** FAILED *** [info] org.graalvm.polyglot.PolyglotException: java.lang.IllegalStateException: java.lang.IllegalAccessException: no such field: com.test.Options2.hash/org.graalvm.polyglot.proxy.ProxyObject/getField [info] at com.oracle.truffle.polyglot.HostFieldDesc$MHImpl.makeGetMethodHandle(HostFieldDesc.java:200) [info] at com.oracle.truffle.polyglot.HostFieldDesc$MHImpl.get(HostFieldDesc.java:156) [info] at com.oracle.truffle.polyglot.HostObject$ReadFieldNode.doCached(HostObject.java:1151) [info] at com.oracle.truffle.polyglot.HostObjectFactory$ReadFieldNodeGen.executeAndSpecialize(HostObjectFactory.java:1272) [info] at com.oracle.truffle.polyglot.HostObjectFactory$ReadFieldNodeGen.execute(HostObjectFactory.java:1237) [info] at com.oracle.truffle.polyglot.HostObject.readMember(HostObject.java:239) [info] at com.oracle.truffle.polyglot.HostObjectGen$InteropLibraryExports$Cached.readMemberNode_AndSpecialize(HostObjectGen.java:1221) [info] at com.oracle.truffle.polyglot.HostObjectGen$InteropLibraryExports$Cached.readMember(HostObjectGen.java:1199) [info] at com.oracle.truffle.api.interop.InteropLibraryGen$CachedDispatch.readMember(InteropLibraryGen.java:2983) [info] at com.oracle.truffle.js.nodes.access.PropertyGetNode$ForeignPropertyGetNode.foreignGet(PropertyGetNode.java:913) [info] ... [

bug

Most helpful comment

Never mind. 19.1.0 just dropped and I'm not seeing the issue any more. Thank you!

All 4 comments

This looks like a class loader issue.

Here's the cause of the IllegalAccessException:
java.lang.LinkageError: loader constraint violation: when resolving field "hash" the class loader (instance of <bootloader>) of the referring class, com/test/Options, and the class loader (instance of sbt/internal/inc/classpath/ClasspathUtilities$$anon$1) for the field's resolved type, com/test/MapProxyObject, have different Class objects for that type

Thanks for the report! A fix for the bug is in master (https://github.com/oracle/graal/commit/c53864afa586192fe12ac0ac07430c936f3fc7cc) and will be included in the next release.

Hello... I was eager to try the fix with the 19.0.2 release. Did this fix make it in that build? The problem still exists in 19.0.2.

Never mind. 19.1.0 just dropped and I'm not seeing the issue any more. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

sebthom picture sebthom  路  3Comments

guaporocco picture guaporocco  路  3Comments

jinwuxia picture jinwuxia  路  3Comments

helloguo picture helloguo  路  3Comments