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

Side by Side Diff: trunk/src/base/android/jni_generator/testNativeExportsOption.golden

Issue 492713002: Revert 290810 "Make class lookup lazy in jni_generator when usin..." (Closed) Base URL: svn://svn.chromium.org/chrome/
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 2014 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/SampleForTests 8 // org/chromium/example/jni_generator/SampleForTests
9 9
10 #ifndef org_chromium_example_jni_generator_SampleForTests_JNI 10 #ifndef org_chromium_example_jni_generator_SampleForTests_JNI
11 #define org_chromium_example_jni_generator_SampleForTests_JNI 11 #define org_chromium_example_jni_generator_SampleForTests_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 kSampleForTestsClassPath[] = 21 const char kSampleForTestsClassPath[] =
22 "org/chromium/example/jni_generator/SampleForTests"; 22 "org/chromium/example/jni_generator/SampleForTests";
23 #if __clang__
24 #pragma clang diagnostic push
25 #pragma clang diagnostic ignored "-Wunused-function"
26 #endif
27 // Leaking this jclass as we cannot use LazyInstance from some threads. 23 // Leaking this jclass as we cannot use LazyInstance from some threads.
28 base::subtle::AtomicWord g_SampleForTests_clazz = 0; 24 jclass g_SampleForTests_clazz = NULL;
29 jclass SampleForTests_clazz(JNIEnv* env) {
30 return base::android::LazyGetClass(env, kSampleForTestsClassPath,
31 &g_SampleForTests_clazz);
32 }
33 #if __clang__
34 #pragma clang diagnostic pop
35 #endif
36 25
37 } // namespace 26 } // namespace
38 27
39 extern "C" { 28 extern "C" {
40 29
41 static jint Init(JNIEnv* env, jobject jcaller); 30 static jint Init(JNIEnv* env, jobject jcaller);
42 31
43 __attribute__((visibility("default"))) 32 __attribute__((visibility("default")))
44 jint 33 jint
45 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_na tiveInit(JNIEnv* 34 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_na tiveInit(JNIEnv*
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 Test* native = reinterpret_cast<Test*>(nativeTest); 72 Test* native = reinterpret_cast<Test*>(nativeTest);
84 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); 73 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
85 return native->Method(env, jcaller, arg1); 74 return native->Method(env, jcaller, arg1);
86 } 75 }
87 76
88 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0; 77 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0;
89 static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj, 78 static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj,
90 JniIntWrapper iParam) { 79 JniIntWrapper iParam) {
91 /* Must call RegisterNativesImpl() */ 80 /* Must call RegisterNativesImpl() */
92 CHECK_CLAZZ(env, obj, 81 CHECK_CLAZZ(env, obj,
93 SampleForTests_clazz(env)); 82 g_SampleForTests_clazz);
94 jmethodID method_id = 83 jmethodID method_id =
95 base::android::MethodID::LazyGet< 84 base::android::MethodID::LazyGet<
96 base::android::MethodID::TYPE_INSTANCE>( 85 base::android::MethodID::TYPE_INSTANCE>(
97 env, SampleForTests_clazz(env), 86 env, g_SampleForTests_clazz,
98 "testMethodWithParam", 87 "testMethodWithParam",
99 88
100 "(" 89 "("
101 "I" 90 "I"
102 ")" 91 ")"
103 "V", 92 "V",
104 &g_SampleForTests_testMethodWithParam); 93 &g_SampleForTests_testMethodWithParam);
105 94
106 env->CallVoidMethod(obj, 95 env->CallVoidMethod(obj,
107 method_id, as_jint(iParam)); 96 method_id, as_jint(iParam));
108 jni_generator::CheckException(env); 97 jni_generator::CheckException(env);
109 98
110 } 99 }
111 100
112 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParamAndReturn = 101 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParamAndReturn =
113 0; 102 0;
114 static base::android::ScopedJavaLocalRef<jstring> 103 static base::android::ScopedJavaLocalRef<jstring>
115 Java_SampleForTests_testMethodWithParamAndReturn(JNIEnv* env, jobject obj, 104 Java_SampleForTests_testMethodWithParamAndReturn(JNIEnv* env, jobject obj,
116 JniIntWrapper iParam) { 105 JniIntWrapper iParam) {
117 /* Must call RegisterNativesImpl() */ 106 /* Must call RegisterNativesImpl() */
118 CHECK_CLAZZ(env, obj, 107 CHECK_CLAZZ(env, obj,
119 SampleForTests_clazz(env), NULL); 108 g_SampleForTests_clazz, NULL);
120 jmethodID method_id = 109 jmethodID method_id =
121 base::android::MethodID::LazyGet< 110 base::android::MethodID::LazyGet<
122 base::android::MethodID::TYPE_INSTANCE>( 111 base::android::MethodID::TYPE_INSTANCE>(
123 env, SampleForTests_clazz(env), 112 env, g_SampleForTests_clazz,
124 "testMethodWithParamAndReturn", 113 "testMethodWithParamAndReturn",
125 114
126 "(" 115 "("
127 "I" 116 "I"
128 ")" 117 ")"
129 "Ljava/lang/String;", 118 "Ljava/lang/String;",
130 &g_SampleForTests_testMethodWithParamAndReturn); 119 &g_SampleForTests_testMethodWithParamAndReturn);
131 120
132 jstring ret = 121 jstring ret =
133 static_cast<jstring>(env->CallObjectMethod(obj, 122 static_cast<jstring>(env->CallObjectMethod(obj,
134 method_id, as_jint(iParam))); 123 method_id, as_jint(iParam)));
135 jni_generator::CheckException(env); 124 jni_generator::CheckException(env);
136 return base::android::ScopedJavaLocalRef<jstring>(env, ret); 125 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
137 } 126 }
138 127
139 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithParam = 0; 128 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithParam = 0;
140 static jint Java_SampleForTests_testStaticMethodWithParam(JNIEnv* env, 129 static jint Java_SampleForTests_testStaticMethodWithParam(JNIEnv* env,
141 JniIntWrapper iParam) { 130 JniIntWrapper iParam) {
142 /* Must call RegisterNativesImpl() */ 131 /* Must call RegisterNativesImpl() */
143 CHECK_CLAZZ(env, SampleForTests_clazz(env), 132 CHECK_CLAZZ(env, g_SampleForTests_clazz,
144 SampleForTests_clazz(env), 0); 133 g_SampleForTests_clazz, 0);
145 jmethodID method_id = 134 jmethodID method_id =
146 base::android::MethodID::LazyGet< 135 base::android::MethodID::LazyGet<
147 base::android::MethodID::TYPE_STATIC>( 136 base::android::MethodID::TYPE_STATIC>(
148 env, SampleForTests_clazz(env), 137 env, g_SampleForTests_clazz,
149 "testStaticMethodWithParam", 138 "testStaticMethodWithParam",
150 139
151 "(" 140 "("
152 "I" 141 "I"
153 ")" 142 ")"
154 "I", 143 "I",
155 &g_SampleForTests_testStaticMethodWithParam); 144 &g_SampleForTests_testStaticMethodWithParam);
156 145
157 jint ret = 146 jint ret =
158 env->CallStaticIntMethod(SampleForTests_clazz(env), 147 env->CallStaticIntMethod(g_SampleForTests_clazz,
159 method_id, as_jint(iParam)); 148 method_id, as_jint(iParam));
160 jni_generator::CheckException(env); 149 jni_generator::CheckException(env);
161 return ret; 150 return ret;
162 } 151 }
163 152
164 static base::subtle::AtomicWord g_SampleForTests_testMethodWithNoParam = 0; 153 static base::subtle::AtomicWord g_SampleForTests_testMethodWithNoParam = 0;
165 static jdouble Java_SampleForTests_testMethodWithNoParam(JNIEnv* env) { 154 static jdouble Java_SampleForTests_testMethodWithNoParam(JNIEnv* env) {
166 /* Must call RegisterNativesImpl() */ 155 /* Must call RegisterNativesImpl() */
167 CHECK_CLAZZ(env, SampleForTests_clazz(env), 156 CHECK_CLAZZ(env, g_SampleForTests_clazz,
168 SampleForTests_clazz(env), 0); 157 g_SampleForTests_clazz, 0);
169 jmethodID method_id = 158 jmethodID method_id =
170 base::android::MethodID::LazyGet< 159 base::android::MethodID::LazyGet<
171 base::android::MethodID::TYPE_STATIC>( 160 base::android::MethodID::TYPE_STATIC>(
172 env, SampleForTests_clazz(env), 161 env, g_SampleForTests_clazz,
173 "testMethodWithNoParam", 162 "testMethodWithNoParam",
174 163
175 "(" 164 "("
176 ")" 165 ")"
177 "D", 166 "D",
178 &g_SampleForTests_testMethodWithNoParam); 167 &g_SampleForTests_testMethodWithNoParam);
179 168
180 jdouble ret = 169 jdouble ret =
181 env->CallStaticDoubleMethod(SampleForTests_clazz(env), 170 env->CallStaticDoubleMethod(g_SampleForTests_clazz,
182 method_id); 171 method_id);
183 jni_generator::CheckException(env); 172 jni_generator::CheckException(env);
184 return ret; 173 return ret;
185 } 174 }
186 175
187 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithNoParam = 176 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithNoParam =
188 0; 177 0;
189 static base::android::ScopedJavaLocalRef<jstring> 178 static base::android::ScopedJavaLocalRef<jstring>
190 Java_SampleForTests_testStaticMethodWithNoParam(JNIEnv* env) { 179 Java_SampleForTests_testStaticMethodWithNoParam(JNIEnv* env) {
191 /* Must call RegisterNativesImpl() */ 180 /* Must call RegisterNativesImpl() */
192 CHECK_CLAZZ(env, SampleForTests_clazz(env), 181 CHECK_CLAZZ(env, g_SampleForTests_clazz,
193 SampleForTests_clazz(env), NULL); 182 g_SampleForTests_clazz, NULL);
194 jmethodID method_id = 183 jmethodID method_id =
195 base::android::MethodID::LazyGet< 184 base::android::MethodID::LazyGet<
196 base::android::MethodID::TYPE_STATIC>( 185 base::android::MethodID::TYPE_STATIC>(
197 env, SampleForTests_clazz(env), 186 env, g_SampleForTests_clazz,
198 "testStaticMethodWithNoParam", 187 "testStaticMethodWithNoParam",
199 188
200 "(" 189 "("
201 ")" 190 ")"
202 "Ljava/lang/String;", 191 "Ljava/lang/String;",
203 &g_SampleForTests_testStaticMethodWithNoParam); 192 &g_SampleForTests_testStaticMethodWithNoParam);
204 193
205 jstring ret = 194 jstring ret =
206 static_cast<jstring>(env->CallStaticObjectMethod(SampleForTests_clazz(env), 195 static_cast<jstring>(env->CallStaticObjectMethod(g_SampleForTests_clazz,
207 method_id)); 196 method_id));
208 jni_generator::CheckException(env); 197 jni_generator::CheckException(env);
209 return base::android::ScopedJavaLocalRef<jstring>(env, ret); 198 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
210 } 199 }
211 }; // extern "C" 200 }; // extern "C"
212 201
213 // Step 3: RegisterNatives. 202 // Step 3: RegisterNatives.
214 203
215 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) { 204 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) {
216 base::subtle::Release_Store(&g_SampleForTests_clazz, 205 g_SampleForTests_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz));
217 static_cast<base::subtle::AtomicWord>(env->NewWeakGlobalRef(clazz));
218 206
219 return true; 207 return true;
220 } 208 }
221 209
222 extern "C" JNIEXPORT bool JNICALL 210 extern "C" JNIEXPORT bool JNICALL
223 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInitNativeClass(JN IEnv* 211 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInitNativeClass(JN IEnv*
224 env, jclass clazz) { 212 env, jclass clazz) {
225 return RegisterNativesImpl(env, clazz); 213 return RegisterNativesImpl(env, clazz);
226 } 214 }
227 215
228 #endif // org_chromium_example_jni_generator_SampleForTests_JNI 216 #endif // org_chromium_example_jni_generator_SampleForTests_JNI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698