I want to pass a structure pointer from Java to c,where it gets updated with the required values and use those values back at my java code. I searched all over internet but couldn't find any required pages, nor i couldn't get any good examples. Please help me with this. I am new to Java/JNI.
Below is my JNI c file used
typedef struct _struct1{
char a;
char b;
short c;
char d[20];
int e;
int f;
}struct1;
typedef struct _struct2{
struct1 g[12];
}struct2;
JNIEXPORT void JNICALL Java_com_example_test_GetDataFromC(
JNIEnv *env,
jobject /* this */,jobject foo) {
/* I want to update foo with the values from struct2*/
test_application(&struct2);
}
Below is the java code
public class struct1{
public char a;
public char b;
public short c;
public char []d= new char[20];
public int e;
public int f;
}
public class struct2{
public struct1[]g= new struct1[12];
}
protected void onCreate(Bundle savedInstanceState) {
struct2 foo = new struct2();
GetDataFromC(foo);
printf("f = %d \n",foo.g[1].f);
}
public native void GetDataFromC(struct2);