我在窗口中做得很好,但在 linux 中失败了。我想要做的是使用 -Xcompile.invokedynamic=true 参数将 ruby 脚本编译为 java 字节码:
[sxu3@** rubyscript]$ jrubyc -Xcompile.invokedynamic=true hello.rb OptionParser::InvalidOption:无效选项:-Xcompile.invokedynamic=true 在 /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1542 完成 抓住 org/jruby/RubyKernel.java:1282 在 /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1540 完成 parse_in_order 在 /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1380 抓住 org/jruby/RubyKernel.java:1282 parse_in_order 在 /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1347 命令!在/homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1341 置换!在/homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1432 解析!在/homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:1453 compile_argv 在 /homes/sxu3/tools/jruby-1.7.10/lib/ruby/shared/jruby/compiler.rb:83 在 /homes/sxu3/tools/jruby-1.7.10/lib/ruby/1.9/optparse.rb:882 初始化 compile_argv 在 /homes/sxu3/tools/jruby-1.7.10/lib/ruby/shared/jruby/compiler.rb:35 (根)在 /homes/sxu3/tools/jruby-1.7.10/bin/jrubyc:5 [sxu3@** rubyscript]$ jrubyc -Xcompile.invokedynamic=true hello.rb ^C [sxu3@** rubyscript]$ which jrubyc ~/tools/jruby-1.7.10/bin/jrubyc [sxu3@** rubyscript]$ jruby -v jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on Java HotSpot(TM) Server VM 1.7.0_51-b13 [linux-i386] [sxu3@** rubyscript]$ [sxu3@** rubyscript]$ uname -a Linux .. 2.6.32-358.23.2.el6.x86_64 #1 SMP 10 月 16 日星期三 18:37:12 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
如果没有 -Xcompile.invokedynamic=true,jrubyc 可以工作,但生成的字节码中没有任何 invokedynamic 指令。还,
"jrubyc -Xcompile.invokedynamic=true hello.rb"
在窗口中工作,我在窗口的类文件中看到了 invokedynamic。
我将所有其他 jrubyc 属性(.jrubyrc)保留为默认值
hello.rb 是一行 ruby 脚本:
puts "hello world"
我也试过 jrubyc 1.7.6 和同样的错误。任何人都可以提供一些线索吗?
[更新]:
最后,我认为异常表明 jrubyc 不支持 -Xcompile.invokedynamic=true 选项。jruby wiki 页面说 jruby,而不是“jrubyc”可以使用选项。