summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2020-09-24 18:39:27 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2020-09-24 22:07:05 +0100
commit666a1ab787f8124ca00a9ddb0985bb2fe25305a6 (patch)
tree9eb16d2034ed31a1c59684fad3f76f9b5e7d1f35
parent5fad8b26e0c82fc7461e2f6136e1061fe8509181 (diff)
Move jniGetReferent to its only user (framework).
So we can better implement optimizations like caching the method ID needed for jniGetReferent. Bug: 168471625 Test: m Change-Id: I22cb6cdf8b29e8ad0a0a6b6e7a20c3491e3a65f1
-rw-r--r--core/jni/core_jni_helpers.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/jni/core_jni_helpers.h b/core/jni/core_jni_helpers.h
index eeda275b811c..ad8aeb20ab3e 100644
--- a/core/jni/core_jni_helpers.h
+++ b/core/jni/core_jni_helpers.h
@@ -90,6 +90,12 @@ static inline int RegisterMethodsOrDie(JNIEnv* env, const char* className,
return res;
}
+static inline jobject jniGetReferent(JNIEnv* env, jobject ref) {
+ jclass cls = FindClassOrDie(env, "java/lang/ref/Reference");
+ jmethodID get = GetMethodIDOrDie(env, cls, "get", "()Ljava/lang/Object;");
+ return env->CallObjectMethod(ref, get);
+}
+
/**
* Read the specified field from jobject, and convert to std::string.
* If the field cannot be obtained, return defaultValue.