DeleteLocalRef
void DeleteLocalRef(JNIEnv *env, jobject localRef);
Deletes the local reference pointed to by
localRef
.LINKAGE:
Index 23 in the JNIEnv interface function table.
PARAMETERS of DeleteLocalRef
env
: the JNI interface pointer.localRef
: a local reference.
Example -DeleteLocalRef
/* This code is OK */ jstring MyNewString(JNIEnv *env, jchar *chars, jint len) { static jclass stringClass = NULL; ... if (stringClass == NULL) { jclass localRefCls = (*env)->FindClass(env, "java/lang/String"); if (localRefCls == NULL) { return NULL; /* exception thrown */ } /* Create a global reference */ stringClass = (*env)->NewGlobalRef(env, localRefCls); /* The local reference is no longer useful */ (*env)->DeleteLocalRef(env, localRefCls); /* Is the global reference created successfully? */ if (stringClass == NULL) { return NULL; /* out of memory exception thrown */ } } ... }