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
obj.setData(bar)
// 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
real
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,
so
we need to use those java classes directly with the syntax
Java::class_name.
So, to convert an array to a java array we can use this syntax: