Skip to Main Content

GetIntArrayElements lost data

892086Jan 31 2012 — edited Jan 31 2012

I am doing a Java program and it´s using an external library. It is C++ and I have done a header file with the JNI´s header whit a mapper one-to-one for Java-C
C++ and Java are compiled on 64bit with gcc and jdk1.6_0_27 and I generate the new library
ok, it´s working but with problems. After debug the code, I watch that when Java pass a Int array and C recovers it whit ‘getIntArryElements(…..)’ some elements are lost.
I watch that C recovers only the pairs Java Array´s elements, ex:
Java pass the array: int[] javaArray = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
Now C reads only: int[] cArray ={0, 2, 4, 6, 8}
This is my code:
Java_IntArray_Method(JNIEnv *env, jobject obj, jintArray arr)
jint *cArray;
cArray = (env)->GetIntArrayElements(env, arr, 0);

Thank You
Post Details
Added on Jan 31 2012
1 comment