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

Unified Diff: base/android/jni_generator/golden_sample_for_tests_jni.h

Issue 472553002: Make class lookup lazy in jni_generator when using lazy method lookup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
« no previous file with comments | « base/android/jni_android.cc ('k') | base/android/jni_generator/jni_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/jni_generator/golden_sample_for_tests_jni.h
diff --git a/base/android/jni_generator/golden_sample_for_tests_jni.h b/base/android/jni_generator/golden_sample_for_tests_jni.h
index 7dbf71eb99719e00e0b30a91b8ee9a6fd8d77808..939875263b08cb7ec93009782e15649071078a80 100644
--- a/base/android/jni_generator/golden_sample_for_tests_jni.h
+++ b/base/android/jni_generator/golden_sample_for_tests_jni.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -24,12 +24,22 @@ const char kSampleForTestsClassPath[] =
"org/chromium/example/jni_generator/SampleForTests";
const char kInnerStructBClassPath[] =
"org/chromium/example/jni_generator/SampleForTests$InnerStructB";
+#if __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-function"
+#endif
// Leaking this jclass as we cannot use LazyInstance from some threads.
jclass g_InnerStructA_clazz = NULL;
+jclass InnerStructA_clazz(JNIEnv*) { return g_InnerStructA_clazz; }
// Leaking this jclass as we cannot use LazyInstance from some threads.
jclass g_SampleForTests_clazz = NULL;
+jclass SampleForTests_clazz(JNIEnv*) { return g_SampleForTests_clazz; }
// Leaking this jclass as we cannot use LazyInstance from some threads.
jclass g_InnerStructB_clazz = NULL;
+jclass InnerStructB_clazz(JNIEnv*) { return g_InnerStructB_clazz; }
+#if __clang__
+#pragma clang diagnostic pop
+#endif
} // namespace
@@ -99,11 +109,11 @@ static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj,
JniIntWrapper bar) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_SampleForTests_clazz, 0);
+ SampleForTests_clazz(env), 0);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_SampleForTests_clazz,
+ env, SampleForTests_clazz(env),
"javaMethod",
"("
@@ -123,12 +133,12 @@ static jint Java_SampleForTests_javaMethod(JNIEnv* env, jobject obj,
static base::subtle::AtomicWord g_SampleForTests_staticJavaMethod = 0;
static jboolean Java_SampleForTests_staticJavaMethod(JNIEnv* env) {
/* Must call RegisterNativesImpl() */
- CHECK_CLAZZ(env, g_SampleForTests_clazz,
- g_SampleForTests_clazz, false);
+ CHECK_CLAZZ(env, SampleForTests_clazz(env),
+ SampleForTests_clazz(env), false);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_STATIC>(
- env, g_SampleForTests_clazz,
+ env, SampleForTests_clazz(env),
"staticJavaMethod",
"("
@@ -137,7 +147,7 @@ static jboolean Java_SampleForTests_staticJavaMethod(JNIEnv* env) {
&g_SampleForTests_staticJavaMethod);
jboolean ret =
- env->CallStaticBooleanMethod(g_SampleForTests_clazz,
+ env->CallStaticBooleanMethod(SampleForTests_clazz(env),
method_id);
jni_generator::CheckException(env);
return ret;
@@ -148,11 +158,11 @@ static void Java_SampleForTests_packagePrivateJavaMethod(JNIEnv* env, jobject
obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_SampleForTests_clazz);
+ SampleForTests_clazz(env));
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_SampleForTests_clazz,
+ env, SampleForTests_clazz(env),
"packagePrivateJavaMethod",
"("
@@ -171,11 +181,11 @@ static void Java_SampleForTests_methodThatThrowsException(JNIEnv* env, jobject
obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_SampleForTests_clazz);
+ SampleForTests_clazz(env));
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_SampleForTests_clazz,
+ env, SampleForTests_clazz(env),
"methodThatThrowsException",
"("
@@ -194,12 +204,12 @@ static base::android::ScopedJavaLocalRef<jobject>
JniIntWrapper i,
jstring s) {
/* Must call RegisterNativesImpl() */
- CHECK_CLAZZ(env, g_InnerStructA_clazz,
- g_InnerStructA_clazz, NULL);
+ CHECK_CLAZZ(env, InnerStructA_clazz(env),
+ InnerStructA_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_STATIC>(
- env, g_InnerStructA_clazz,
+ env, InnerStructA_clazz(env),
"create",
"("
@@ -211,7 +221,7 @@ static base::android::ScopedJavaLocalRef<jobject>
&g_InnerStructA_create);
jobject ret =
- env->CallStaticObjectMethod(g_InnerStructA_clazz,
+ env->CallStaticObjectMethod(InnerStructA_clazz(env),
method_id, l, as_jint(i), s);
jni_generator::CheckException(env);
return base::android::ScopedJavaLocalRef<jobject>(env, ret);
@@ -222,11 +232,11 @@ static void Java_SampleForTests_addStructA(JNIEnv* env, jobject obj, jobject a)
{
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_SampleForTests_clazz);
+ SampleForTests_clazz(env));
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_SampleForTests_clazz,
+ env, SampleForTests_clazz(env),
"addStructA",
"("
@@ -246,11 +256,11 @@ static void Java_SampleForTests_iterateAndDoSomething(JNIEnv* env, jobject obj)
{
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_SampleForTests_clazz);
+ SampleForTests_clazz(env));
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_SampleForTests_clazz,
+ env, SampleForTests_clazz(env),
"iterateAndDoSomething",
"("
@@ -268,11 +278,11 @@ static base::subtle::AtomicWord g_InnerStructB_getKey = 0;
static jlong Java_InnerStructB_getKey(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_InnerStructB_clazz, 0);
+ InnerStructB_clazz(env), 0);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_InnerStructB_clazz,
+ env, InnerStructB_clazz(env),
"getKey",
"("
@@ -292,11 +302,11 @@ static base::android::ScopedJavaLocalRef<jstring>
Java_InnerStructB_getValue(JNIEnv* env, jobject obj) {
/* Must call RegisterNativesImpl() */
CHECK_CLAZZ(env, obj,
- g_InnerStructB_clazz, NULL);
+ InnerStructB_clazz(env), NULL);
jmethodID method_id =
base::android::MethodID::LazyGet<
base::android::MethodID::TYPE_INSTANCE>(
- env, g_InnerStructB_clazz,
+ env, InnerStructB_clazz(env),
"getValue",
"("
@@ -379,11 +389,11 @@ static bool RegisterNativesImpl(JNIEnv* env) {
const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests);
- if (env->RegisterNatives(g_SampleForTests_clazz,
+ if (env->RegisterNatives(SampleForTests_clazz(env),
kMethodsSampleForTests,
kMethodsSampleForTestsSize) < 0) {
jni_generator::HandleRegistrationError(
- env, g_SampleForTests_clazz, __FILE__);
+ env, SampleForTests_clazz(env), __FILE__);
return false;
}
« no previous file with comments | « base/android/jni_android.cc ('k') | base/android/jni_generator/jni_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698