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

Side by Side Diff: base/android/jni_generator/testEagerCalledByNativesOption.golden

Issue 491043002: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file is autogenerated by 5 // This file is autogenerated by
6 // base/android/jni_generator/jni_generator.py 6 // base/android/jni_generator/jni_generator.py
7 // For 7 // For
8 // org/chromium/example/jni_generator/Test 8 // org/chromium/example/jni_generator/Test
9 9
10 #ifndef org_chromium_example_jni_generator_Test_JNI 10 #ifndef org_chromium_example_jni_generator_Test_JNI
11 #define org_chromium_example_jni_generator_Test_JNI 11 #define org_chromium_example_jni_generator_Test_JNI
12 12
13 #include <jni.h> 13 #include <jni.h>
14 14
15 #include "base/android/jni_generator/jni_generator_helper.h" 15 #include "base/android/jni_generator/jni_generator_helper.h"
16 16
17 #include "base/android/jni_int_wrapper.h" 17 #include "base/android/jni_int_wrapper.h"
18 18
19 // Step 1: forward declarations. 19 // Step 1: forward declarations.
20 namespace { 20 namespace {
21 const char kTestClassPath[] = "org/chromium/example/jni_generator/Test"; 21 const char kTestClassPath[] = "org/chromium/example/jni_generator/Test";
22 // Leaking this jclass as we cannot use LazyInstance from some threads. 22 // Leaking this jclass as we cannot use LazyInstance from some threads.
23 jclass g_Test_clazz = NULL; 23 jclass g_Test_clazz = NULL;
24 #define Test_clazz(env) g_Test_clazz
24 jmethodID g_Test_testMethodWithParam = NULL; 25 jmethodID g_Test_testMethodWithParam = NULL;
25 jmethodID g_Test_testStaticMethodWithParam = NULL; 26 jmethodID g_Test_testStaticMethodWithParam = NULL;
26 jmethodID g_Test_testMethodWithNoParam = NULL; 27 jmethodID g_Test_testMethodWithNoParam = NULL;
27 jmethodID g_Test_testStaticMethodWithNoParam = NULL; 28 jmethodID g_Test_testStaticMethodWithNoParam = NULL;
28 } // namespace 29 } // namespace
29 30
30 // Step 2: method stubs. 31 // Step 2: method stubs.
31 static jint Method(JNIEnv* env, jobject jcaller, 32 static jint Method(JNIEnv* env, jobject jcaller,
32 jlong nativeTest, 33 jlong nativeTest,
33 jint arg1) { 34 jint arg1) {
34 Test* native = reinterpret_cast<Test*>(nativeTest); 35 Test* native = reinterpret_cast<Test*>(nativeTest);
35 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); 36 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
36 return native->Method(env, jcaller, arg1); 37 return native->Method(env, jcaller, arg1);
37 } 38 }
38 39
39 namespace { 40 namespace {
40 41
41 static void testMethodWithParam(JNIEnv* env, jobject obj, JniIntWrapper iParam) 42 static void testMethodWithParam(JNIEnv* env, jobject obj, JniIntWrapper iParam)
42 { 43 {
43 env->CallVoidMethod(obj, 44 env->CallVoidMethod(obj,
44 g_Test_testMethodWithParam, as_jint(iParam)); 45 g_Test_testMethodWithParam, as_jint(iParam));
45 46
46 } 47 }
47 48
48 static jint testStaticMethodWithParam(JNIEnv* env, JniIntWrapper iParam) { 49 static jint testStaticMethodWithParam(JNIEnv* env, JniIntWrapper iParam) {
49 jint ret = env->CallStaticIntMethod(g_Test_clazz, 50 jint ret = env->CallStaticIntMethod(Test_clazz(env),
50 g_Test_testStaticMethodWithParam, as_jint(iParam)); 51 g_Test_testStaticMethodWithParam, as_jint(iParam));
51 return ret; 52 return ret;
52 } 53 }
53 54
54 static jdouble testMethodWithNoParam(JNIEnv* env) { 55 static jdouble testMethodWithNoParam(JNIEnv* env) {
55 jdouble ret = env->CallStaticDoubleMethod(g_Test_clazz, 56 jdouble ret = env->CallStaticDoubleMethod(Test_clazz(env),
56 g_Test_testMethodWithNoParam); 57 g_Test_testMethodWithNoParam);
57 return ret; 58 return ret;
58 } 59 }
59 60
60 static base::android::ScopedJavaLocalRef<jstring> 61 static base::android::ScopedJavaLocalRef<jstring>
61 testStaticMethodWithNoParam(JNIEnv* env) { 62 testStaticMethodWithNoParam(JNIEnv* env) {
62 jstring ret = static_cast<jstring>(env->CallStaticObjectMethod(g_Test_clazz, 63 jstring ret =
64 static_cast<jstring>(env->CallStaticObjectMethod(Test_clazz(env),
63 g_Test_testStaticMethodWithNoParam)); 65 g_Test_testStaticMethodWithNoParam));
64 return base::android::ScopedJavaLocalRef<jstring>(env, ret); 66 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
65 } 67 }
66 } // namespace 68 } // namespace
67 69
68 // Step 3: RegisterNatives. 70 // Step 3: RegisterNatives.
69 71
70 static const JNINativeMethod kMethodsTest[] = { 72 static const JNINativeMethod kMethodsTest[] = {
71 { "nativeMethod", 73 { "nativeMethod",
72 "(" 74 "("
73 "J" 75 "J"
74 "I" 76 "I"
75 ")" 77 ")"
76 "I", reinterpret_cast<void*>(Method) }, 78 "I", reinterpret_cast<void*>(Method) },
77 }; 79 };
78 80
79 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) { 81 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) {
80 g_Test_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz)); 82 g_Test_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz));
81 83
82 const int kMethodsTestSize = arraysize(kMethodsTest); 84 const int kMethodsTestSize = arraysize(kMethodsTest);
83 85
84 if (env->RegisterNatives(g_Test_clazz, 86 if (env->RegisterNatives(Test_clazz(env),
85 kMethodsTest, 87 kMethodsTest,
86 kMethodsTestSize) < 0) { 88 kMethodsTestSize) < 0) {
87 jni_generator::HandleRegistrationError( 89 jni_generator::HandleRegistrationError(
88 env, g_Test_clazz, __FILE__); 90 env, Test_clazz(env), __FILE__);
89 return false; 91 return false;
90 } 92 }
91 93
92 g_Test_testMethodWithParam = env->GetMethodID( 94 g_Test_testMethodWithParam = env->GetMethodID(
93 g_Test_clazz, 95 Test_clazz(env),
94 "testMethodWithParam", 96 "testMethodWithParam",
95 "(" 97 "("
96 "I" 98 "I"
97 ")" 99 ")"
98 "V"); 100 "V");
99 if (g_Test_testMethodWithParam == NULL) { 101 if (g_Test_testMethodWithParam == NULL) {
100 return false; 102 return false;
101 } 103 }
102 104
103 g_Test_testStaticMethodWithParam = env->GetStaticMethodID( 105 g_Test_testStaticMethodWithParam = env->GetStaticMethodID(
104 g_Test_clazz, 106 Test_clazz(env),
105 "testStaticMethodWithParam", 107 "testStaticMethodWithParam",
106 "(" 108 "("
107 "I" 109 "I"
108 ")" 110 ")"
109 "I"); 111 "I");
110 if (g_Test_testStaticMethodWithParam == NULL) { 112 if (g_Test_testStaticMethodWithParam == NULL) {
111 return false; 113 return false;
112 } 114 }
113 115
114 g_Test_testMethodWithNoParam = env->GetStaticMethodID( 116 g_Test_testMethodWithNoParam = env->GetStaticMethodID(
115 g_Test_clazz, 117 Test_clazz(env),
116 "testMethodWithNoParam", 118 "testMethodWithNoParam",
117 "(" 119 "("
118 ")" 120 ")"
119 "D"); 121 "D");
120 if (g_Test_testMethodWithNoParam == NULL) { 122 if (g_Test_testMethodWithNoParam == NULL) {
121 return false; 123 return false;
122 } 124 }
123 125
124 g_Test_testStaticMethodWithNoParam = env->GetStaticMethodID( 126 g_Test_testStaticMethodWithNoParam = env->GetStaticMethodID(
125 g_Test_clazz, 127 Test_clazz(env),
126 "testStaticMethodWithNoParam", 128 "testStaticMethodWithNoParam",
127 "(" 129 "("
128 ")" 130 ")"
129 "Ljava/lang/String;"); 131 "Ljava/lang/String;");
130 if (g_Test_testStaticMethodWithNoParam == NULL) { 132 if (g_Test_testStaticMethodWithNoParam == NULL) {
131 return false; 133 return false;
132 } 134 }
133 135
134 return true; 136 return true;
135 } 137 }
136 138
137 extern "C" JNIEXPORT bool JNICALL 139 extern "C" JNIEXPORT bool JNICALL
138 Java_org_chromium_example_jni_generator_Test_nativeInitNativeClass(JNIEnv* env, 140 Java_org_chromium_example_jni_generator_Test_nativeInitNativeClass(JNIEnv* env,
139 jclass clazz) { 141 jclass clazz) {
140 return RegisterNativesImpl(env, clazz); 142 return RegisterNativesImpl(env, clazz);
141 } 143 }
142 144
143 #endif // org_chromium_example_jni_generator_Test_JNI 145 #endif // org_chromium_example_jni_generator_Test_JNI
OLDNEW
« no previous file with comments | « base/android/jni_generator/testConstantsFromJavaP.golden ('k') | base/android/jni_generator/testFromJavaP.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698