Forum: JRuby jrubyc AOT Java compilation fails

D4c223beb610f1e5baa56a0b764e24a9?d=identicon&s=25 Marko Asplund (Guest)
on 2012-05-01 18:46
(Received via mailing list)
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
https://github.com/jruby/jruby/wiki/JRubyCompiler 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
Fe3bda5efab4f341304dee628e9a5dc2?d=identicon&s=25 Peter Lamber (Guest)
on 2012-05-03 03:58
(Received via mailing list)
Hi,

yes, there are a lot of restrictions. Everything what Ruby is capable
of,
but Java not.
For example, declaring Methods with an question mark. Java won't allow
that.
That's also what the error is trying to point out.
It would be great if the erroneous line would be indicated...somebody
should file a ticket for that ^^

Kind regards
Peter

2012/5/1 Marko Asplund <marko.asplund@ixonos.com>
D4c223beb610f1e5baa56a0b764e24a9?d=identicon&s=25 Marko Asplund (Guest)
on 2012-05-03 22:08
(Received via mailing list)
Hi,

I'm having trouble identifying the erroneous line from the compiler
error output:
it doesn't seem to include any reference to the script being compiled.
the verbose flag doesn't seem to help.
How do I find out which line is causing the compiler to fail?


best regards,

marko
Fe3bda5efab4f341304dee628e9a5dc2?d=identicon&s=25 Peter Lamber (Guest)
on 2012-05-04 05:16
(Received via mailing list)
I think you won't. Try to request this at  http://jira.codehaus.org ,
maybe
they will add it.
What you can do is to refactor every method with a question mark.

2012/5/4 Marko Asplund <marko.asplund@ixonos.com>
D4c223beb610f1e5baa56a0b764e24a9?d=identicon&s=25 Marko Asplund (Guest)
on 2012-05-06 11:33
(Received via mailing list)
filed an improvement request JRUBY-6643 for this.

thanks, marko
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.