Jrubyc bug triggered by more than 3 function arguments?

Hello List,

I am having problems with jrubyc.

It might be a bug.

I wrote this file:

#!/usr/bin/env jruby

my_class.rb

require ‘java’

class MyClass
def my_fnc(a, b, c)
end
end

I ran jrubyc:

a@z2:/pt/z2/api$
a@z2:/pt/z2/api$ jrubyc --javac my_class.rb
Generating Java class MyClass to /pt/z2/api/MyClass.java
javac -d /pt/z2/api -cp /pt/z2/jruby151/lib/jruby.jar:.
/pt/z2/api/MyClass.java
a@z2:/pt/z2/api$
a@z2:/pt/z2/api$

Then I edited the file and added a 4th argument to method: my_func()

I see this:

a@z2:/pt/z2/api$
a@z2:/pt/z2/api$ cat my_class.rb
#!/usr/bin/env jruby

my_class.rb

require ‘java’

class MyClass
def my_fnc(a, b, c, d)
end
end
a@z2:/pt/z2/api$
a@z2:/pt/z2/api$
a@z2:/pt/z2/api$ jrubyc --javac my_class.rb
Generating Java class MyClass to /pt/z2/api/MyClass.java
javac -d /pt/z2/api -cp /pt/z2/jruby151/lib/jruby.jar:.
/pt/z2/api/MyClass.java
/pt/z2/api/MyClass.java:75: cannot find symbol
symbol : method
invoke(org.jruby.runtime.ThreadContext,MyClass,java.lang.String,org.jruby.runtime.builtin.IRubyObject,org.jruby.runtime.builtin.IRubyObject,org.jruby.runtime.builtin.IRubyObject,org.jruby.runtime.builtin.IRubyObject)
location: class org.jruby.javasupport.util.RuntimeHelpers
IRubyObject ruby_result =
RuntimeHelpers.invoke(ruby.getCurrentContext(), this, “my_fnc”,
ruby_a, ruby_b, ruby_c, ruby_d);
^
1 error
a@z2:/pt/z2/api$
a@z2:/pt/z2/api$
a@z2:/pt/z2/api$

Then I edited the file and removed the 4th argument from the method:
my_func()

I see this:

a@z2:/pt/z2/api$
a@z2:/pt/z2/api$
a@z2:/pt/z2/api$ cat my_class.rb
#!/usr/bin/env jruby

my_class.rb

require ‘java’

class MyClass
def my_fnc(a, b, c)
end
end
a@z2:/pt/z2/api$
a@z2:/pt/z2/api$
a@z2:/pt/z2/api$ jrubyc --javac my_class.rb
Generating Java class MyClass to /pt/z2/api/MyClass.java
javac -d /pt/z2/api -cp /pt/z2/jruby151/lib/jruby.jar:.
/pt/z2/api/MyClass.java
a@z2:/pt/z2/api$
a@z2:/pt/z2/api$
a@z2:/pt/z2/api$

So, it looks like jrubyc prevents me from having more than 3 arguments
in my function definition.

Here is my JRuby version:

a@z2:/pt/z2/api$
a@z2:/pt/z2/api$ jruby --version
jruby 1.5.1 (ruby 1.8.7 patchlevel 249) (2010-06-06 f3a3480) (Java
HotSpot™ Client VM 1.6.0_21) [i386-java]
a@z2:/pt/z2/api$
a@z2:/pt/z2/api$

I see this behavior on both my Linux box and my Mac.

Is this a known bug?


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Wed, Aug 11, 2010 at 7:40 PM, Audrey L. [email protected]
wrote:

Hello List,

I am having problems with jrubyc.

It might be a bug.

Yuck. It’s a bug. File it, and I’ll make it a high priority to fix
(and provide a workaround or patch for the short term).

It’s always the simplest things that burn you. :frowning:

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Here’s the fix…please still file a bug so we can track it
appropriately.

diff --git a/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb
b/lib/ruby/site_ruby/shared/jrub
index 1b680df…114b85e 100644
— a/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb
+++ b/lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb
@@ -580,6 +580,11 @@ JAVA
return @passed_args if @passed_args

   @passed_args = var_names.map {|a| "ruby_#{a}"}.join(', ')
  •  # handle more than three args by array-boxing
    
  •  @passed_args = "new IRubyObject[] \{#{@passed_args}\}" if 
    

args.size > 3
+

  •  # add leading comma if we have any args
     @passed_args = ', ' + @passed_args if args.size > 0
    
    end

On Thu, Aug 12, 2010 at 5:55 PM, Charles Oliver N.
[email protected] wrote:

It’s always the simplest things that burn you. :frowning:

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Done:

http://jira.codehaus.org/browse/JRUBY-5011

On 8/12/10, Charles Oliver N. [email protected] wrote:


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email