Wednesday, April 24, 2013

jni jnienv GetArrayLength example c c++ java


GetArrayLength


jsize GetArrayLength(JNIEnv *env, jarray array);

Returns the number of elements in the array.
LINKAGE:
Index 171 in the JNIEnv interface function table.
PARAMETERS of GetArrayLength

env: the JNI interface pointer.

array: a Java array object.

RETURNS of GetArrayLength

Returns the length of the array.
Example of GetArrayLength
JNIEXPORT jint JNICALL Java_com_Test_Enroll( JNIEnv* env, jobject thiz, jbyteArray jpSeed ){
     blobData_t* bd = malloc( sizeof(blobData_t) );
     bd->length = (*env)->GetArrayLength( env, jpSeed );
     .......
}
JNIEXPORT jint JNICALL Java_com_Test_Enroll( JNIEnv* env, jobject thiz, jbyteArray jpSeed ){
     blobData_t* bd = malloc( sizeof(blobData_t) );
     .......
     jbyte* bytes = (*env)->GetByteArrayElements( env, jpSeed, 0 );
     bd->data[1] = bytes[1];
}