Problems with compiling Ruby files


#1

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


#2

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 :slight_smile:

  • Charlie

Fouad M. 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