Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

JRUBY-5011 (jrubyc --java): 'cannot find symbol' if function def has …

…more than 3 arguments
  • Loading branch information...
commit 7ca06d70f1cc61dde479f8f86bc1f9a75a152be4 1 parent d65e1a8
@enebo enebo authored
Showing with 20 additions and 3 deletions.
  1. +20 −3 lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb
View
23 lib/ruby/site_ruby/shared/jruby/compiler/java_class.rb
@@ -480,6 +480,9 @@ def imports_string
end
class RubyMethod
+ # How many arguments we can invoke without needing to box arguments
+ MAX_UNBOXED_ARITY_LENGTH = 3
+
def initialize(ruby_class, name, java_signature = nil, annotations = [])
@ruby_class = ruby_class
@name = name
@@ -495,6 +498,10 @@ def constructor?
false
end
+ def arity
+ typed_args.size
+ end
+
def to_s
declarator_string do
<<-JAVA
@@ -519,7 +526,13 @@ def annotations_string
end
def conversion_string(var_names)
- var_names.map { |a| " IRubyObject ruby_#{a} = JavaUtil.convertJavaToRuby(__ruby__, #{a});"}.join("\n")
+ if arity <= MAX_UNBOXED_ARITY_LENGTH
+ var_names.map { |a| " IRubyObject ruby_#{a} = JavaUtil.convertJavaToRuby(__ruby__, #{a});"}.join("\n")
+ else
+ str = " IRubyObject ruby_args[] = new IRubyObject[#{arity}];\n"
+ var_names.each_with_index { |a, i| str += " ruby_args[#{i}] = JavaUtil.convertJavaToRuby(__ruby__, #{a});\n" }
+ str
+ end
end
# FIXME: We should allow all valid modifiers
@@ -574,8 +587,12 @@ def var_names
def passed_args
return @passed_args if @passed_args
- @passed_args = var_names.map {|a| "ruby_#{a}"}.join(', ')
- @passed_args = ', ' + @passed_args if args.size > 0
+ if arity <= MAX_UNBOXED_ARITY_LENGTH
+ @passed_args = var_names.map {|a| "ruby_#{a}"}.join(', ')
+ @passed_args = ', ' + @passed_args if args.size > 0
+ else
+ @passed_args = ", ruby_args";
+ end
end
def return_type
Please sign in to comment.
Something went wrong with that request. Please try again.