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

Side by Side Diff: base/android/jni_generator/testNativeExportsOption.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 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 // Leaking this jclass as we cannot use LazyInstance from some threads. 23 // Leaking this jclass as we cannot use LazyInstance from some threads.
24 jclass g_SampleForTests_clazz = NULL; 24 base::subtle::AtomicWord g_SampleForTests_clazz = 0;
25 #define SampleForTests_clazz(env) base::android::LazyGetClass(env, kSampleForTes tsClassPath, &g_SampleForTests_clazz)
25 26
26 } // namespace 27 } // namespace
27 28
28 extern "C" { 29 extern "C" {
29 30
30 static jint Init(JNIEnv* env, jobject jcaller); 31 static jint Init(JNIEnv* env, jobject jcaller);
31 32
32 __attribute__((visibility("default"))) 33 __attribute__((visibility("default")))
33 jint 34 jint
34 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_na tiveInit(JNIEnv* 35 Java_org_chromium_example_jni_1generator_SampleForTests_00024MyInnerClass_na tiveInit(JNIEnv*
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 Test* native = reinterpret_cast<Test*>(nativeTest); 73 Test* native = reinterpret_cast<Test*>(nativeTest);
73 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); 74 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
74 return native->Method(env, jcaller, arg1); 75 return native->Method(env, jcaller, arg1);
75 } 76 }
76 77
77 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0; 78 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParam = 0;
78 static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj, 79 static void Java_SampleForTests_testMethodWithParam(JNIEnv* env, jobject obj,
79 JniIntWrapper iParam) { 80 JniIntWrapper iParam) {
80 /* Must call RegisterNativesImpl() */ 81 /* Must call RegisterNativesImpl() */
81 CHECK_CLAZZ(env, obj, 82 CHECK_CLAZZ(env, obj,
82 g_SampleForTests_clazz); 83 SampleForTests_clazz(env));
83 jmethodID method_id = 84 jmethodID method_id =
84 base::android::MethodID::LazyGet< 85 base::android::MethodID::LazyGet<
85 base::android::MethodID::TYPE_INSTANCE>( 86 base::android::MethodID::TYPE_INSTANCE>(
86 env, g_SampleForTests_clazz, 87 env, SampleForTests_clazz(env),
87 "testMethodWithParam", 88 "testMethodWithParam",
88 89
89 "(" 90 "("
90 "I" 91 "I"
91 ")" 92 ")"
92 "V", 93 "V",
93 &g_SampleForTests_testMethodWithParam); 94 &g_SampleForTests_testMethodWithParam);
94 95
95 env->CallVoidMethod(obj, 96 env->CallVoidMethod(obj,
96 method_id, as_jint(iParam)); 97 method_id, as_jint(iParam));
97 jni_generator::CheckException(env); 98 jni_generator::CheckException(env);
98 99
99 } 100 }
100 101
101 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParamAndReturn = 102 static base::subtle::AtomicWord g_SampleForTests_testMethodWithParamAndReturn =
102 0; 103 0;
103 static base::android::ScopedJavaLocalRef<jstring> 104 static base::android::ScopedJavaLocalRef<jstring>
104 Java_SampleForTests_testMethodWithParamAndReturn(JNIEnv* env, jobject obj, 105 Java_SampleForTests_testMethodWithParamAndReturn(JNIEnv* env, jobject obj,
105 JniIntWrapper iParam) { 106 JniIntWrapper iParam) {
106 /* Must call RegisterNativesImpl() */ 107 /* Must call RegisterNativesImpl() */
107 CHECK_CLAZZ(env, obj, 108 CHECK_CLAZZ(env, obj,
108 g_SampleForTests_clazz, NULL); 109 SampleForTests_clazz(env), NULL);
109 jmethodID method_id = 110 jmethodID method_id =
110 base::android::MethodID::LazyGet< 111 base::android::MethodID::LazyGet<
111 base::android::MethodID::TYPE_INSTANCE>( 112 base::android::MethodID::TYPE_INSTANCE>(
112 env, g_SampleForTests_clazz, 113 env, SampleForTests_clazz(env),
113 "testMethodWithParamAndReturn", 114 "testMethodWithParamAndReturn",
114 115
115 "(" 116 "("
116 "I" 117 "I"
117 ")" 118 ")"
118 "Ljava/lang/String;", 119 "Ljava/lang/String;",
119 &g_SampleForTests_testMethodWithParamAndReturn); 120 &g_SampleForTests_testMethodWithParamAndReturn);
120 121
121 jstring ret = 122 jstring ret =
122 static_cast<jstring>(env->CallObjectMethod(obj, 123 static_cast<jstring>(env->CallObjectMethod(obj,
123 method_id, as_jint(iParam))); 124 method_id, as_jint(iParam)));
124 jni_generator::CheckException(env); 125 jni_generator::CheckException(env);
125 return base::android::ScopedJavaLocalRef<jstring>(env, ret); 126 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
126 } 127 }
127 128
128 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithParam = 0; 129 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithParam = 0;
129 static jint Java_SampleForTests_testStaticMethodWithParam(JNIEnv* env, 130 static jint Java_SampleForTests_testStaticMethodWithParam(JNIEnv* env,
130 JniIntWrapper iParam) { 131 JniIntWrapper iParam) {
131 /* Must call RegisterNativesImpl() */ 132 /* Must call RegisterNativesImpl() */
132 CHECK_CLAZZ(env, g_SampleForTests_clazz, 133 CHECK_CLAZZ(env, SampleForTests_clazz(env),
133 g_SampleForTests_clazz, 0); 134 SampleForTests_clazz(env), 0);
134 jmethodID method_id = 135 jmethodID method_id =
135 base::android::MethodID::LazyGet< 136 base::android::MethodID::LazyGet<
136 base::android::MethodID::TYPE_STATIC>( 137 base::android::MethodID::TYPE_STATIC>(
137 env, g_SampleForTests_clazz, 138 env, SampleForTests_clazz(env),
138 "testStaticMethodWithParam", 139 "testStaticMethodWithParam",
139 140
140 "(" 141 "("
141 "I" 142 "I"
142 ")" 143 ")"
143 "I", 144 "I",
144 &g_SampleForTests_testStaticMethodWithParam); 145 &g_SampleForTests_testStaticMethodWithParam);
145 146
146 jint ret = 147 jint ret =
147 env->CallStaticIntMethod(g_SampleForTests_clazz, 148 env->CallStaticIntMethod(SampleForTests_clazz(env),
148 method_id, as_jint(iParam)); 149 method_id, as_jint(iParam));
149 jni_generator::CheckException(env); 150 jni_generator::CheckException(env);
150 return ret; 151 return ret;
151 } 152 }
152 153
153 static base::subtle::AtomicWord g_SampleForTests_testMethodWithNoParam = 0; 154 static base::subtle::AtomicWord g_SampleForTests_testMethodWithNoParam = 0;
154 static jdouble Java_SampleForTests_testMethodWithNoParam(JNIEnv* env) { 155 static jdouble Java_SampleForTests_testMethodWithNoParam(JNIEnv* env) {
155 /* Must call RegisterNativesImpl() */ 156 /* Must call RegisterNativesImpl() */
156 CHECK_CLAZZ(env, g_SampleForTests_clazz, 157 CHECK_CLAZZ(env, SampleForTests_clazz(env),
157 g_SampleForTests_clazz, 0); 158 SampleForTests_clazz(env), 0);
158 jmethodID method_id = 159 jmethodID method_id =
159 base::android::MethodID::LazyGet< 160 base::android::MethodID::LazyGet<
160 base::android::MethodID::TYPE_STATIC>( 161 base::android::MethodID::TYPE_STATIC>(
161 env, g_SampleForTests_clazz, 162 env, SampleForTests_clazz(env),
162 "testMethodWithNoParam", 163 "testMethodWithNoParam",
163 164
164 "(" 165 "("
165 ")" 166 ")"
166 "D", 167 "D",
167 &g_SampleForTests_testMethodWithNoParam); 168 &g_SampleForTests_testMethodWithNoParam);
168 169
169 jdouble ret = 170 jdouble ret =
170 env->CallStaticDoubleMethod(g_SampleForTests_clazz, 171 env->CallStaticDoubleMethod(SampleForTests_clazz(env),
171 method_id); 172 method_id);
172 jni_generator::CheckException(env); 173 jni_generator::CheckException(env);
173 return ret; 174 return ret;
174 } 175 }
175 176
176 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithNoParam = 177 static base::subtle::AtomicWord g_SampleForTests_testStaticMethodWithNoParam =
177 0; 178 0;
178 static base::android::ScopedJavaLocalRef<jstring> 179 static base::android::ScopedJavaLocalRef<jstring>
179 Java_SampleForTests_testStaticMethodWithNoParam(JNIEnv* env) { 180 Java_SampleForTests_testStaticMethodWithNoParam(JNIEnv* env) {
180 /* Must call RegisterNativesImpl() */ 181 /* Must call RegisterNativesImpl() */
181 CHECK_CLAZZ(env, g_SampleForTests_clazz, 182 CHECK_CLAZZ(env, SampleForTests_clazz(env),
182 g_SampleForTests_clazz, NULL); 183 SampleForTests_clazz(env), NULL);
183 jmethodID method_id = 184 jmethodID method_id =
184 base::android::MethodID::LazyGet< 185 base::android::MethodID::LazyGet<
185 base::android::MethodID::TYPE_STATIC>( 186 base::android::MethodID::TYPE_STATIC>(
186 env, g_SampleForTests_clazz, 187 env, SampleForTests_clazz(env),
187 "testStaticMethodWithNoParam", 188 "testStaticMethodWithNoParam",
188 189
189 "(" 190 "("
190 ")" 191 ")"
191 "Ljava/lang/String;", 192 "Ljava/lang/String;",
192 &g_SampleForTests_testStaticMethodWithNoParam); 193 &g_SampleForTests_testStaticMethodWithNoParam);
193 194
194 jstring ret = 195 jstring ret =
195 static_cast<jstring>(env->CallStaticObjectMethod(g_SampleForTests_clazz, 196 static_cast<jstring>(env->CallStaticObjectMethod(SampleForTests_clazz(env),
196 method_id)); 197 method_id));
197 jni_generator::CheckException(env); 198 jni_generator::CheckException(env);
198 return base::android::ScopedJavaLocalRef<jstring>(env, ret); 199 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
199 } 200 }
200 }; // extern "C" 201 }; // extern "C"
201 202
202 // Step 3: RegisterNatives. 203 // Step 3: RegisterNatives.
203 204
204 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) { 205 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) {
205 g_SampleForTests_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz)); 206 base::subtle::Release_Store(&g_SampleForTests_clazz,
207 static_cast<base::subtle::AtomicWord>(env->NewWeakGlobalRef(clazz));
206 208
207 return true; 209 return true;
208 } 210 }
209 211
210 extern "C" JNIEXPORT bool JNICALL 212 extern "C" JNIEXPORT bool JNICALL
211 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInitNativeClass(JN IEnv* 213 Java_org_chromium_example_jni_1generator_SampleForTests_nativeInitNativeClass(JN IEnv*
212 env, jclass clazz) { 214 env, jclass clazz) {
213 return RegisterNativesImpl(env, clazz); 215 return RegisterNativesImpl(env, clazz);
214 } 216 }
215 217
216 #endif // org_chromium_example_jni_generator_SampleForTests_JNI 218 #endif // org_chromium_example_jni_generator_SampleForTests_JNI
OLDNEW
« no previous file with comments | « base/android/jni_generator/testMultipleJNIAdditionalImport.golden ('k') | base/android/jni_generator/testNatives.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698