Your Java method is returning an array of arrays. For some reason, rJava's coercion is confused by that, so you'll have to help it along.
Individual rows can be converted like this:
r_vector <- .jevalArray(data[[1]])
This came out transposed from what I expected:
r_matrix <- sapply(data, .jevalArray)
This seems to work as expected:
r_matrix <- do.call(rbind, lapply(data, .jevalArray))
For what it's worth, the Java code I used to test this out is here:
import java.util.Arrays;
public class Foo {
public double[][] method() {
double[][] data = { {1.1, 1.2, 1.3},
{2.1, 2.2, 2.3} };
return data;
}
public double[] getArray() {
double[] data = {9.9,8.8,7.7};
return data;
}
public static void main(String[] args) {
Foo foo = new Foo();
System.out.println(Arrays.toString(foo.method()));
}
}
And, for completeness, on the R side:
library(rJava)
.jinit()
.jaddClassPath(path='.')
foo <- new( J('Foo'))
data <- foo$method()
one_row <- .jevalArray( data[[1]] )
r_matrix <- sapply(data, .jevalArray)
r_matrix <- do.call(rbind, lapply(data, .jevalArray))