I'm trying to convert a jbooleanArray
with 128 elements (always) to a C++ array of bool
s with 128 elements also.
extern "C" {
JNIEXPORT jboolean Java_com_app_flutter_1app_JNI_loadBufferNative(
JNIEnv *env, jbooleanArray jMidiNotes) {
bool midiNotes[128] = {false};
*reinterpret_cast<uint64_t*>(midiNotes) = *env->GetBooleanArrayElements(jMidiNotes, nullptr);
*reinterpret_cast<uint64_t*>(midiNotes + 64) = *env->GetBooleanArrayElements(jMidiNotes + 64, nullptr);
I believe GetBooleanArrayElements
returns jboolean*
, and it looks like a jboolean
is uint8_t
in C++ (strange).
What am I doing wrong here? I get a crash JNI DETECTED ERROR IN APPLICATION: use of invalid jobject 0x7ff426b390
.
Since jboolean = uint8_t
I also tried
*reinterpret_cast<uint64_t*>(midiNotes + 64) = *env->GetBooleanArrayElements(jMidiNotes + 8, nullptr);
but I get the same crash