Jni has methods GetArrayElements and GetPrimitiveArrayCritical.
I know the *critical methods add gc lock to prevent gc when jni code is executing in critical sections, but if jni code is executing non-critical methods and gc happens, the array elements may be moved by gc. In this situation, native code may hold a wrong address. I don't know how jvm handle this, or if i misunderstand something.