Hi,
I’m trying to compile a Ruby script to Java source code but the
compilation
fails with the following error message.
The same script successfully compiles to JVM bytecode.
Are there any known restrictions as to what kind of scripts can be
compiled
to Java?
I’ve tried reading the compiler page
JRubyCompiler · jruby/jruby Wiki · GitHub but it doesn’t seem to
contain any discussion on this matter.
Here’s the error message:
jrubyc --verbose --java ruby
Failure during compilation of file src/main/ruby/foo.rb:
org.jruby.parser.ParserSyntaxException: syntax error, unexpected
QUESTION
org/jruby/parser/JavaSignatureParser.java:324:in yyerror' org/jruby/parser/JavaSignatureParser.java:431:in
yyparse’
org/jruby/parser/JavaSignatureParser.java:28:in parse' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:142:in
build_signature’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:219:in
ClassNodeWalker' org/jruby/RubyKernel.java:2045:in
instance_eval’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:35:in
visit_args_node' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:179:in
with_node’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:34:in
visit_args_node' org/jruby/RubyProc.java:270:in
call’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:231:in
ClassNodeWalker' org/jruby/RubyKernel.java:2045:in
instance_eval’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:35:in
visit_defn_node' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:179:in
with_node’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:34:in
visit_defn_node' org/jruby/RubyProc.java:270:in
call’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:263:in
ClassNodeWalker' org/jruby/RubyKernel.java:2045:in
instance_eval’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:35:in
visit_newline_node' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:179:in
with_node’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:34:in
visit_newline_node' org/jruby/RubyProc.java:270:in
call’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:259:in
ClassNodeWalker' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/builtin/java/java.util.rb:7:in
each’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:259:in
ClassNodeWalker' org/jruby/RubyKernel.java:2045:in
instance_eval’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:35:in
visit_block_node' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:179:in
with_node’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:34:in
visit_block_node' org/jruby/RubyProc.java:270:in
call’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:225:in
ClassNodeWalker' org/jruby/RubyKernel.java:2045:in
instance_eval’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:35:in
visit_class_node' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:179:in
with_node’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:34:in
visit_class_node' org/jruby/RubyProc.java:270:in
call’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:263:in
ClassNodeWalker' org/jruby/RubyKernel.java:2045:in
instance_eval’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:35:in
visit_newline_node' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:179:in
with_node’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:34:in
visit_newline_node' org/jruby/RubyProc.java:270:in
call’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:259:in
ClassNodeWalker' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/builtin/java/java.util.rb:7:in
each’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:259:in
ClassNodeWalker' org/jruby/RubyKernel.java:2045:in
instance_eval’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:35:in
visit_block_node' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:179:in
with_node’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:34:in
visit_block_node' org/jruby/RubyProc.java:270:in
call’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:270:in
ClassNodeWalker' org/jruby/RubyKernel.java:2045:in
instance_eval’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:35:in
visit_root_node' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:179:in
with_node’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:34:in
visit_root_node' org/jruby/RubyProc.java:270:in
call’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb:8:in
generate_java' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler.rb:138:in
compile_files_with_options’
org/jruby/RubyProc.java:270:in call' org/jruby/RubyProc.java:220:in
call’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler.rb:208:in
compile_files_with_options' org/jruby/RubyArray.java:1615:in
each’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler.rb:207:in
compile_files_with_options' org/jruby/RubyArray.java:1615:in
each’
/Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler.rb:198:in
compile_files_with_options' /Users/aspluma/projects/jruby/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/compiler.rb:90:in
compile_argv’
/Users/aspluma/projects/jruby/jruby-1.6.7/bin/jrubyc:5:in `(root)’
Compilation FAILED: 1 error(s) encountered
marko