简体   繁体   中英

JNI Exception: jarray is an invalid global reference

Getting the following exception from JNI via CheckJNI.

JNI DETECTED ERROR IN APPLICATION: jarray is an invalid global reference: 0x8f635e1e (0xdead4321)

Happens during:

uint32_t* ConvertIntArray(JNIEnv *env, jclass cls, jintArray intArray)
{
   return (*env)->GetIntArrayElements(env, intArray, NULL);
}

which is called from:

uint32_t* indexes = ConvertIntArray(env, cls, planeLengths);

which is in:

jlong Java_<censored>(JNIEnv *env, jclass cls, jlong state, jintArray planeLengths)

Everything happens within the above function so no global references are made. planeLengths is passed directly into ConvertIntArray which should return the uint32 pointer of it. Google has no results on the JNI error either.

Note: The above lines are after all the C preprocessing is done. There are several macros that substitute in different code which is why the ConvertIntArray function seems pointless.

My colleage and myself are stumped. Any thoughts?

So, it turns out it was a memory corruption. In the question, I truncated several of the long parameters to make the question shorter. As it turned out, Java was passing in ints instead of longs which being smaller variables, shifted some of the pointers back. So, it basically corrupted the jobjects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM