Question

I would like to deal with a byte array which is retrieved from java callback function. However, I got an error 'JNIEnv' has no member named 'GetObjectElements'

jmethodID FuncGetArray = GetStaticMethodID(clazz, "GetArray", "()[B");
jobject data_obj = env->CallStaticObjectMethod(clazz, FuncGetArray);
const jboolean is_copy = JNI_FALSE;
jbyte *byte_array = env->GetObjectElements(data_obj, is_copy);

Can I get the pointer to get the byte array in a easy way instead of retrieving each element and copying it.

Was it helpful?

Solution

I think the function you are looking for is GetByteArrayElements. You can cast the data_obj you have to a jbyteArray and pass it to that function.

Also you should be passing a pointer to is_copy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top