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
This commit is contained in:
Nicolas Geoffray
2020-09-24 18:39:27 +01:00
parent 5fad8b26e0
commit 666a1ab787

View File

@@ -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.