My Go code is as below
package main
import "C"
//export MyFunc
func MyFunc(records []string) [][]string {
records := make([][]string, 0)
.
.
.
return records
}
I need to run this go file through Java Native Access.
Java code for same is as below-
public Class MyClass {
public interface MyInterface extends Library {
String[][] MyFunc(String[] records);
}
static{
MyObj = (MyClass) Native.loadLibrary("/path/to/so_file", MyClass.class);
}
public static void main(String[] args) {
String[] strArray = {"abc1|HLJHSA|hgah","abc2|ksahd|","abc3|876987","abc4"};
String[][] records1 = MyObj.MyFunc(strArray );
}
}
I did all steps correctly but i am getting below error
Exception in thread "main" java.lang.IllegalArgumentException: Unsupported return type class [[Ljava.lang.String; in function MyFunc
at com.sun.jna.Function.invoke(Function.java:373)
at com.sun.jna.Function.invoke(Function.java:223)
at com.sun.jna.Library$Handler.invoke(Library.java:204)
I also tried with
ArrayList<ArrayList> MyFunc(String[] records); and
List<List> MyFunc(String[] records);
Please Help me to find correct equivalent for make([][]string, 0) in java