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

Side by Side Diff: trunk/src/base/android/jni_generator/testEagerCalledByNativesOption.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 (c) 2012 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 #if __clang__
23 #pragma clang diagnostic push
24 #pragma clang diagnostic ignored "-Wunused-function"
25 #endif
26 // Leaking this jclass as we cannot use LazyInstance from some threads. 22 // Leaking this jclass as we cannot use LazyInstance from some threads.
27 jclass g_Test_clazz = NULL; 23 jclass g_Test_clazz = NULL;
28 jclass Test_clazz(JNIEnv*) { return g_Test_clazz; }
29 #if __clang__
30 #pragma clang diagnostic pop
31 #endif
32 jmethodID g_Test_testMethodWithParam = NULL; 24 jmethodID g_Test_testMethodWithParam = NULL;
33 jmethodID g_Test_testStaticMethodWithParam = NULL; 25 jmethodID g_Test_testStaticMethodWithParam = NULL;
34 jmethodID g_Test_testMethodWithNoParam = NULL; 26 jmethodID g_Test_testMethodWithNoParam = NULL;
35 jmethodID g_Test_testStaticMethodWithNoParam = NULL; 27 jmethodID g_Test_testStaticMethodWithNoParam = NULL;
36 } // namespace 28 } // namespace
37 29
38 // Step 2: method stubs. 30 // Step 2: method stubs.
39 static jint Method(JNIEnv* env, jobject jcaller, 31 static jint Method(JNIEnv* env, jobject jcaller,
40 jlong nativeTest, 32 jlong nativeTest,
41 jint arg1) { 33 jint arg1) {
42 Test* native = reinterpret_cast<Test*>(nativeTest); 34 Test* native = reinterpret_cast<Test*>(nativeTest);
43 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0); 35 CHECK_NATIVE_PTR(env, jcaller, native, "Method", 0);
44 return native->Method(env, jcaller, arg1); 36 return native->Method(env, jcaller, arg1);
45 } 37 }
46 38
47 namespace { 39 namespace {
48 40
49 static void testMethodWithParam(JNIEnv* env, jobject obj, JniIntWrapper iParam) 41 static void testMethodWithParam(JNIEnv* env, jobject obj, JniIntWrapper iParam)
50 { 42 {
51 env->CallVoidMethod(obj, 43 env->CallVoidMethod(obj,
52 g_Test_testMethodWithParam, as_jint(iParam)); 44 g_Test_testMethodWithParam, as_jint(iParam));
53 45
54 } 46 }
55 47
56 static jint testStaticMethodWithParam(JNIEnv* env, JniIntWrapper iParam) { 48 static jint testStaticMethodWithParam(JNIEnv* env, JniIntWrapper iParam) {
57 jint ret = env->CallStaticIntMethod(Test_clazz(env), 49 jint ret = env->CallStaticIntMethod(g_Test_clazz,
58 g_Test_testStaticMethodWithParam, as_jint(iParam)); 50 g_Test_testStaticMethodWithParam, as_jint(iParam));
59 return ret; 51 return ret;
60 } 52 }
61 53
62 static jdouble testMethodWithNoParam(JNIEnv* env) { 54 static jdouble testMethodWithNoParam(JNIEnv* env) {
63 jdouble ret = env->CallStaticDoubleMethod(Test_clazz(env), 55 jdouble ret = env->CallStaticDoubleMethod(g_Test_clazz,
64 g_Test_testMethodWithNoParam); 56 g_Test_testMethodWithNoParam);
65 return ret; 57 return ret;
66 } 58 }
67 59
68 static base::android::ScopedJavaLocalRef<jstring> 60 static base::android::ScopedJavaLocalRef<jstring>
69 testStaticMethodWithNoParam(JNIEnv* env) { 61 testStaticMethodWithNoParam(JNIEnv* env) {
70 jstring ret = 62 jstring ret = static_cast<jstring>(env->CallStaticObjectMethod(g_Test_clazz,
71 static_cast<jstring>(env->CallStaticObjectMethod(Test_clazz(env),
72 g_Test_testStaticMethodWithNoParam)); 63 g_Test_testStaticMethodWithNoParam));
73 return base::android::ScopedJavaLocalRef<jstring>(env, ret); 64 return base::android::ScopedJavaLocalRef<jstring>(env, ret);
74 } 65 }
75 } // namespace 66 } // namespace
76 67
77 // Step 3: RegisterNatives. 68 // Step 3: RegisterNatives.
78 69
79 static const JNINativeMethod kMethodsTest[] = { 70 static const JNINativeMethod kMethodsTest[] = {
80 { "nativeMethod", 71 { "nativeMethod",
81 "(" 72 "("
82 "J" 73 "J"
83 "I" 74 "I"
84 ")" 75 ")"
85 "I", reinterpret_cast<void*>(Method) }, 76 "I", reinterpret_cast<void*>(Method) },
86 }; 77 };
87 78
88 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) { 79 static bool RegisterNativesImpl(JNIEnv* env, jclass clazz) {
89 g_Test_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz)); 80 g_Test_clazz = static_cast<jclass>(env->NewWeakGlobalRef(clazz));
90 81
91 const int kMethodsTestSize = arraysize(kMethodsTest); 82 const int kMethodsTestSize = arraysize(kMethodsTest);
92 83
93 if (env->RegisterNatives(Test_clazz(env), 84 if (env->RegisterNatives(g_Test_clazz,
94 kMethodsTest, 85 kMethodsTest,
95 kMethodsTestSize) < 0) { 86 kMethodsTestSize) < 0) {
96 jni_generator::HandleRegistrationError( 87 jni_generator::HandleRegistrationError(
97 env, Test_clazz(env), __FILE__); 88 env, g_Test_clazz, __FILE__);
98 return false; 89 return false;
99 } 90 }
100 91
101 g_Test_testMethodWithParam = env->GetMethodID( 92 g_Test_testMethodWithParam = env->GetMethodID(
102 Test_clazz(env), 93 g_Test_clazz,
103 "testMethodWithParam", 94 "testMethodWithParam",
104 "(" 95 "("
105 "I" 96 "I"
106 ")" 97 ")"
107 "V"); 98 "V");
108 if (g_Test_testMethodWithParam == NULL) { 99 if (g_Test_testMethodWithParam == NULL) {
109 return false; 100 return false;
110 } 101 }
111 102
112 g_Test_testStaticMethodWithParam = env->GetStaticMethodID( 103 g_Test_testStaticMethodWithParam = env->GetStaticMethodID(
113 Test_clazz(env), 104 g_Test_clazz,
114 "testStaticMethodWithParam", 105 "testStaticMethodWithParam",
115 "(" 106 "("
116 "I" 107 "I"
117 ")" 108 ")"
118 "I"); 109 "I");
119 if (g_Test_testStaticMethodWithParam == NULL) { 110 if (g_Test_testStaticMethodWithParam == NULL) {
120 return false; 111 return false;
121 } 112 }
122 113
123 g_Test_testMethodWithNoParam = env->GetStaticMethodID( 114 g_Test_testMethodWithNoParam = env->GetStaticMethodID(
124 Test_clazz(env), 115 g_Test_clazz,
125 "testMethodWithNoParam", 116 "testMethodWithNoParam",
126 "(" 117 "("
127 ")" 118 ")"
128 "D"); 119 "D");
129 if (g_Test_testMethodWithNoParam == NULL) { 120 if (g_Test_testMethodWithNoParam == NULL) {
130 return false; 121 return false;
131 } 122 }
132 123
133 g_Test_testStaticMethodWithNoParam = env->GetStaticMethodID( 124 g_Test_testStaticMethodWithNoParam = env->GetStaticMethodID(
134 Test_clazz(env), 125 g_Test_clazz,
135 "testStaticMethodWithNoParam", 126 "testStaticMethodWithNoParam",
136 "(" 127 "("
137 ")" 128 ")"
138 "Ljava/lang/String;"); 129 "Ljava/lang/String;");
139 if (g_Test_testStaticMethodWithNoParam == NULL) { 130 if (g_Test_testStaticMethodWithNoParam == NULL) {
140 return false; 131 return false;
141 } 132 }
142 133
143 return true; 134 return true;
144 } 135 }
145 136
146 extern "C" JNIEXPORT bool JNICALL 137 extern "C" JNIEXPORT bool JNICALL
147 Java_org_chromium_example_jni_generator_Test_nativeInitNativeClass(JNIEnv* env, 138 Java_org_chromium_example_jni_generator_Test_nativeInitNativeClass(JNIEnv* env,
148 jclass clazz) { 139 jclass clazz) {
149 return RegisterNativesImpl(env, clazz); 140 return RegisterNativesImpl(env, clazz);
150 } 141 }
151 142
152 #endif // org_chromium_example_jni_generator_Test_JNI 143 #endif // org_chromium_example_jni_generator_Test_JNI
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698