Forum: JRuby Problems with compiling Ruby files

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2ced34335d6aca14ea8dec9754191dd2?d=identicon&s=25 Fouad Mardini (Guest)
on 2009-05-11 17:04
(Received via mailing list)
Hello,

I am trying to compile ruby code files to class files and use them
directly
from java applications.
I have a problem with method signatures, I looked into the jruby code
and
discovered the signature method, but unfortunately it's not working

require 'rbconfig'
require 'java'
require 'jruby'
require 'tool/signature'

class Foo
  def bar(x)
    return x + 1
  end
  signature :bar, [java.lang.Integer] => java.lang.Integer
end

# I had to symlink ./tool to ./lib/ruby/site_ruby/1.8/tool for "jruby
Foo.rb" to run without errors

javap gives the following output

Compiled from "Foo.rb"
public class Foo extends org.jruby.ast.executable.AbstractScript{
    public Foo();
    public org.jruby.runtime.builtin.IRubyObject
__file__(org.jruby.runtime.ThreadContext,
org.jruby.runtime.builtin.IRubyObject,
org.jruby.runtime.builtin.IRubyObject[], org.jruby.runtime.Block);
    public org.jruby.runtime.builtin.IRubyObject
class_0$RUBY$Foo(org.jruby.runtime.ThreadContext,
org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.Block);
    public org.jruby.runtime.builtin.IRubyObject
method__1$RUBY$bar(org.jruby.runtime.ThreadContext,
org.jruby.runtime.builtin.IRubyObject,
org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.Block);
    public org.jruby.runtime.builtin.IRubyObject
method__1$RUBY$bar(org.jruby.runtime.ThreadContext,
org.jruby.runtime.builtin.IRubyObject,
org.jruby.runtime.builtin.IRubyObject[], org.jruby.runtime.Block);
    public org.jruby.runtime.builtin.IRubyObject
class_0$RUBY$Foo(org.jruby.runtime.ThreadContext,
org.jruby.runtime.builtin.IRubyObject,
org.jruby.runtime.builtin.IRubyObject[], org.jruby.runtime.Block);
    public org.jruby.runtime.builtin.IRubyObject
load(org.jruby.runtime.ThreadContext,
org.jruby.runtime.builtin.IRubyObject,
org.jruby.runtime.builtin.IRubyObject[], org.jruby.runtime.Block);
    public static void main(java.lang.String[]);
}

which is identical to the output without using the signature method.

PS. I am running jruby right out of git.

Thanks,
/Fouad
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-05-11 19:09
(Received via mailing list)
In the basic jrubyc compiler, the output you see is what you will always
get. The newer "ruby to java" compiler is still in development and
should have a 0.0.1 release some time today.

I will remove tool/compiler2 and tool/signature to avoid this confusion
in the future. You should check out the ruby2java project here:

http://kenai.com/projects/ruby2java

It's all in Ruby as well, so we welcome assistance improving it :)

- Charlie

Fouad Mardini wrote:
> require 'tool/signature'
>
> class_0$RUBY$Foo(org.jruby.runtime.ThreadContext,
> class_0$RUBY$Foo(org.jruby.runtime.ThreadContext,
>
> PS. I am running jruby right out of git.
>
> Thanks,
> /Fouad
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.