Add a helper to get the referent of a Reference.
Change-Id: I8ac5a69fab563e220d48c94e254f5ed3055abe5f
diff --git a/include/nativehelper/JNIHelp.h b/include/nativehelper/JNIHelp.h
index 446a710..2fadcdf 100644
--- a/include/nativehelper/JNIHelp.h
+++ b/include/nativehelper/JNIHelp.h
@@ -97,6 +97,11 @@
void jniSetFileDescriptorOfFD(C_JNIEnv* env, jobject fileDescriptor, int value);
/*
+ * Returns the reference from a java.lang.ref.Reference.
+ */
+jobject jniGetReferent(C_JNIEnv* env, jobject ref);
+
+/*
* Log a message and an exception.
* If exception is NULL, logs the current exception in the JNI environment.
*/
@@ -157,6 +162,10 @@
jniSetFileDescriptorOfFD(&env->functions, fileDescriptor, value);
}
+inline jobject jniGetReferent(JNIEnv* env, jobject ref) {
+ return jniGetReferent(&env->functions, ref);
+}
+
inline void jniLogException(JNIEnv* env, int priority, const char* tag, jthrowable exception = NULL) {
jniLogException(&env->functions, priority, tag, exception);
}