我正在嘗試從 GraalVM 本機映像中的 Java 代碼運行 JS 腳本。Java 代碼如下所示:try (Context context = Context.create("js")) { Value bindings = context.getBindings("js"); bindings.putMember("response", response); bindings.putMember("UTF8", StandardCharsets.UTF_8); context.eval("js", script);} catch (PolyglotException e) { error("Error: " + e, 10);}JS 代碼只是嘗試response通過調用對象的方法來使用該對象,例如: print("Status code: " + response.getStatusCode());這在 GraalVM 中運行時有效,但在創建本機映像時,它失敗并顯示以下錯誤:INVOKE on JavaObject[...] failed due to: Message not supported: INVOKE如果我只是像 in 那樣打印對象print("Response: " + response);,它不會失敗。但是,如果我嘗試在 上調用任何方法response,則會收到此錯誤(偶數toString()或hashCode())。目前還有什么我需要做的嗎,或者這只是 SubstractVM 本機圖像中的一個錯誤?我的 GraalVM 版本:java version "1.8.0_172"Java(TM) SE Runtime Environment (build 1.8.0_172-b11)GraalVM 1.0.0-rc4 (build 25.71-b01-internal-jvmci-0.45, mixed mode)我正在使用的本機圖像命令:native-image --language:js --report-unsupported-elements-at-runtime -jar my.jar
添加回答
舉報
0/150
提交
取消