I have an array of type Foo in my java code which I want to pass to c++. In the c++ code, I also have the same class named Foo. all I want is to transfer this array via JNI.
I have a call like this:
#include "headers/Foo.h"
extern "C"
JNIEXPORT void
JNICALL Java_main_Main_Interface(JNIEnv *env, jobject obj, jobjectArray foo){
jint size = env->GetArrayLength(foo);
Foo cfoo[size];
for(int i = 0; i < size; i++){
cfoo[i] = env->GetObjectArrayElement(foo, i);
}
}
This is, however, giving me an error: Type 'Foo' and 'jobject' are not compatible
I understand this error but what should I do to eliminate it? should I cast the jobject to type Foo? will c++ understand the object that way? or am I missing some JNI calls?