Search code examples
javarrjava

Problem passing String[][] from Java to R using rJava


Is it possible to return from Java a String[][] to R using rJava?

I call the method

public String[][] readFromTable(String tableName, String security,
        String[] fields, String startTime, String endTime, boolean reverse)

from R with

   out <- .jcall(obj, "[[S", "readFromTable", tableName, security, .jarray(fields),
    start, end, reverse)

When I change the return type of the method to String[] everything works just fine, I experimented with the parameters and I am pretty sure that the problem is the String[][].

Has anyone got an idea?

EDIT 1:
Sorry, I forgot the error message:
Error in .jcall(obj, "[[S", "readFromTable", tableName, security, .jarray(fields), : method readFromTable with signature (Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)[[S not found

EDIT 2
I just figured out that it works if I return a Double[][]...so maybe there is a bug in the String JNI implementation in the rJava package but that's hard to believe


Solution

  • [[Ljava/lang/String;

    This will work