Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: base/android/jni_android.cc

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/android/jni_android.cc
diff --git a/base/android/jni_android.cc b/base/android/jni_android.cc
index a2de00aca2a3fcf2ce0c8c82bd06afc48229c256..1b715dc7d544955ed5bc316d8808b6f35cd141fe 100644
--- a/base/android/jni_android.cc
+++ b/base/android/jni_android.cc
@@ -159,10 +159,25 @@ const jobject GetApplicationContext() {
ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env, const char* class_name) {
jclass clazz;
if (!g_class_loader.Get().is_null()) {
+ // ClassLoader.loadClass expects a classname with components separated by
+ // dots instead of the slashes that JNIEnv::FindClass expects. The JNI
+ // generator generates names with slashes, so we have to replace them here.
+ // TODO(torne): move to an approach where we always use ClassLoader except
+ // for the special case of base::android::GetClassLoader(), and change the
+ // JNI generator to generate dot-separated names. http://crbug.com/461773
+ size_t bufsize = strlen(class_name) + 1;
+ char dotted_name[bufsize];
+ memmove(dotted_name, class_name, bufsize);
+ for (size_t i = 0; i < bufsize; ++i) {
+ if (dotted_name[i] == '/') {
+ dotted_name[i] = '.';
+ }
+ }
+
clazz = static_cast<jclass>(
env->CallObjectMethod(g_class_loader.Get().obj(),
g_class_loader_load_class_method_id,
- ConvertUTF8ToJavaString(env, class_name).obj()));
+ ConvertUTF8ToJavaString(env, dotted_name).obj()));
} else {
clazz = env->FindClass(class_name);
}
« no previous file with comments | « base/android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java ('k') | base/android/record_histogram.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698