小编als*_*lso的帖子

Nashorn故障排除"方法代码太大了!" 例外

运行jjsScriptEngine#eval我的JavaScript(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)
Run Code Online (Sandbox Code Playgroud)

我怎样才能弄清楚导致方法代码太大的原因?我已经尝试了一些日志选项jjs(--log=codegen:info),但我没有看到任何指向罪魁祸首.

我已经使用Java版本1.9.0-ea-b34和1.8.0_20-b26进行了测试.

javascript java java-8 nashorn java-9

3
推荐指数
1
解决办法
1313
查看次数

Ruby类,包含和范围

包含模块如何影响范围?具体来说,在这个例子中:

module ModuleA
  class ClassA
    def initialize
      puts "test passed"
    end
  end
end

module ModuleB
  include ModuleA

  # test 1
  C = ClassA.new

  class ClassB
    def initialize
      c = ClassA.new
    end
  end
end

# test 2 and 3 fail without this
#include ModuleB

module ModuleC
  # this doesn't help
  include ModuleB

  # test 2
  ClassB.new

  # test 3
  ModuleB::ClassB.new
end
Run Code Online (Sandbox Code Playgroud)

测试1工作正常,但测试2测试3失败而没有注释掉import ModuleB.

  • 为什么ClassAModuleB(测试1)范围内但不在ClassB
  • 为什么import ModuleB把 …

ruby scope module

1
推荐指数
1
解决办法
5251
查看次数

标签 统计

java ×1

java-8 ×1

java-9 ×1

javascript ×1

module ×1

nashorn ×1

ruby ×1

scope ×1