Android: Replacement for JNIEnv::FindClass that works from any thread
This CL adds a replacement for JNIEnv::FindClass that works from any
thread, i.e. from native C++ threads as well. This function will be used
from the generated JNI code. Long term, we should stop using
classreferenceholder that relies on a hardcoded list of WebRTC classes.
Bug: webrtc:8278
Change-Id: I4f40c744325ac02b73bd8fa479ab50b684429dc2
Reviewed-on: https://webrtc-review.googlesource.com/20223
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20583}
diff --git a/sdk/android/src/jni/classreferenceholder.h b/sdk/android/src/jni/classreferenceholder.h
index 7d8658b..5145c10 100644
--- a/sdk/android/src/jni/classreferenceholder.h
+++ b/sdk/android/src/jni/classreferenceholder.h
@@ -16,6 +16,9 @@
#ifndef SDK_ANDROID_SRC_JNI_CLASSREFERENCEHOLDER_H_
#define SDK_ANDROID_SRC_JNI_CLASSREFERENCEHOLDER_H_
+// TODO(magjed): Remove this whole file and replace with either generated JNI
+// code or class_loader.h.
+
#include <jni.h>
#include <map>
#include <string>
@@ -28,6 +31,9 @@
// FreeGlobalClassReferenceHolder must be called in JNI_UnLoad.
void FreeGlobalClassReferenceHolder();
+// Deprecated. Most cases of finding classes should be done with generated JNI
+// code, and the few remaining cases should use the function from
+// class_loader.h.
// Returns a global reference guaranteed to be valid for the lifetime of the
// process.
jclass FindClass(JNIEnv* jni, const char* name);