Two dimensional ruby array to java array

I’m trying to convert a list of lists of strings in jruby to a
properly typed java array to send to a java function. I’m familiar
with the .to_java method on lists, but I’m not sure how to properly
type everything.

foo = [[“a”, “b”, “c”], [“d”, “e”, “f”]]

bar = foo.to_java(???) <---- what goes here


// in java
public void setData(String[][] args) { … }

What should I pass to to_java so I can call setData without getting a
type error?

Seems this is a recurrent issue, we should clarify it somehow, meanwhile
this spec is plenty of examples:

As a summary, argument symbols for the method to_java are aliases for
java classes, so :string is an alias for java.lang.String or :long is an
alias for the primitive type long, but there aren’t aliases for arrays,
we need to use those java classes directly with the syntax
So, to convert an array to a java array we can use this syntax:


I just wrote a small guide about this in my blog:

I hope it will be useful.


On Wed, Dec 29, 2010 at 10:48 AM, David C.

That’s exactly what I needed. Thank you for the blog post.

On Wed, Dec 29, 2010 at 3:44 AM, David C.