Saturday, April 20, 2013

jni jnienv PushLocalFrame example c c++ java


PushLocalFrame

jint PushLocalFrame(JNIEnv *env, jint capacity);
Creates a new local reference frame, in which at least a given number of local references can be created. Returns 0 on success, a negative number and a pending OutOfMemoryError on failure.
Note that local references already created in previous local frames are still valid in the current local frame.(PushLocalFrame)
LINKAGE:
Index 19 in the JNIEnv interface function table.
SINCE:
JDK/JRE 1.2
Example - PushLocalFrame

 #define N_REFS ... /* the maximum number of local references
                       used in each iteration */
 for (i = 0; i < len; i++) {
     if ((*env)->PushLocalFrame(env, N_REFS) < 0) {
         ... /* out of memory */
     }
     jstr = (*env)->GetObjectArrayElement(env, arr, i);
     ... /* process jstr */
     (*env)->PopLocalFrame(env, NULL);
 }