3

実行中jjsまたはScriptEngine#evalJavaScript ( https://gist.github.com/also/005fd7c200b20f012e10 ) でクラッシュすると、この例外が発生し、それ以上の詳細はありません:

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たが、原因を突き止めるものは何も見当たりませんでした。

Java バージョン 1.9.0-ea-b34 および 1.8.0_20-b26 でテストしました。

4

2 に答える 2

5

Nashorn は、大きすぎるスクリプト/関数を小さなブロックに分割してバイトコードにコンパイルし、JVM によって課されるメソッドごとのバイトコード サイズ制限を回避しようとします。Nashorn スプリッターは、jdk 1.8.0 update 40 で改善されました (開発中、まだリリースされていません - ただし、https://jdk8.java.net/download.htmlから早期アクセスが可能です。それも試してみてください。

于 2014-10-21T03:54:12.270 に答える
3

現在の JDK 8u40 はまだバグをスローしています。以下の詳細なメモを参照してください。

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

また、最新の Nashorn ソースにアクセスして、すばやくデバッグできる可能性もあります。少なくともハック/検証を見つけて、最終的なパッチが提供されるまで使用してください。

于 2014-12-18T09:00:50.937 に答える