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