簡體   English   中英

Nashorn 故障排除“方法代碼太大!” 例外

[英]Troubleshooting Nashorn "Method code too large!" exception

在我的 JavaScript ( https://gist.github.com/also/005fd7c200b20f012e10 ) 上運行jjsScriptEngine#eval因此異常而崩潰,並且沒有更多詳細信息:

Exception in thread "main" java.lang.RuntimeException: Method code too large!
        at jdk.internal.org.objectweb.asm.MethodWriter.getSize(MethodWriter.java:2065)
        at jdk.internal.org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:856)
        at jdk.nashorn.internal.codegen.ClassEmitter.toByteArray(ClassEmitter.java:577)
        at jdk.nashorn.internal.codegen.CompilationPhase$8.transform(CompilationPhase.java:396)
        at jdk.nashorn.internal.codegen.CompilationPhase.apply(CompilationPhase.java:513)
        at jdk.nashorn.internal.codegen.Compiler.compile(Compiler.java:361)
        at jdk.nashorn.internal.runtime.Context.compile(Context.java:1071)
        at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:1019)
        at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:490)
        at jdk.nashorn.tools.Shell.runScripts(Shell.java:306)
        at jdk.nashorn.tools.Shell.run(Shell.java:168)
        at jdk.nashorn.tools.Shell.main(Shell.java:132)
        at jdk.nashorn.tools.Shell.main(Shell.java:111)

如何找出導致方法代碼過大的原因? 我已經嘗試了一些jjs日志選項( --log=codegen:info jjs --log=codegen:info ),但我沒有看到任何指向罪魁禍首的東西。

我已經用 Java 版本 1.9.0-ea-b34 和 1.8.0_20-b26 進行了測試。

Nashorn 嘗試將過大的腳本/函數拆分為較小的塊以編譯為字節碼,以解決 JVM 強加的每個方法的字節碼大小限制。 Nashorn 拆分器在 jdk 1.8.0 更新 40 中得到了改進(正在開發,尚未發布 - 但可以從https://jdk8.java.net/download.html獲得早期訪問權限。您可能也想嘗試一下。

當前的 JDK 8u40 仍在拋出該錯誤。 請參閱有關以下內容的詳細說明:

http://skrishnamachari.wordpress.com/2014/06/18/nashorn-bug/

也有可能訪問最新的 Nashorn 源以便能夠快速調試。 至少找到一個 hack/validate 並讓它堅持使用,直到提供一些最終補丁。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM