Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array#flatten! call in java_import breaks if we import a class with static to_ary #2324

Closed
headius opened this issue Dec 15, 2014 · 0 comments · Fixed by #2334
Closed

Array#flatten! call in java_import breaks if we import a class with static to_ary #2324

headius opened this issue Dec 15, 2014 · 0 comments · Fixed by #2334

Comments

@headius
Copy link
Member

headius commented Dec 15, 2014

I attempted to java_import org.jruby.util.TypeConverter and ran into this error inside Array#flatten! logic:

ArgumentError: wrong number of arguments (0 for 2)
     flatten! at org/jruby/RubyArray.java:2839
  java_import at file:/Users/headius/projects/jruby/lib/jruby.jar!/jruby/java/core_ext/object.rb:20
       (root) at file:/Users/headius/projects/jruby/lib/jruby.jar!/jruby/kernel/jruby/type.rb:3
       (root) at file:/Users/headius/projects/jruby/lib/jruby.jar!/jruby/kernel.rb:1
       (root) at file:/Users/headius/projects/jruby/lib/jruby.jar!/jruby/kernel.rb:4
         load at org/jruby/RubyKernel.java:969
       (root) at :1

The cause: flatten attempts to coerce elements to Array by calling to_ary with no arguments, but TypeConverter defines a static utility method to_ary(ThreadContext, IRubyObject).

The associated lines of code are seen in the trace above. I think we should just back off flatten! call and do something dumber and more manual that just requires everything already be an Array. That will avoid any future issues with unusual method names getting called for coercion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant