Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 16 | |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 17 | #include <memory> |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 18 | #include <type_traits> |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 19 | |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 20 | #include <math.h> |
| 21 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 22 | #include "art_method-inl.h" |
Pavle Batuta | 837e72a | 2016-03-16 11:31:46 +0100 | [diff] [blame] | 23 | #include "base/bit_utils.h" |
David Sehr | 79e2607 | 2018-04-06 17:58:50 -0700 | [diff] [blame] | 24 | #include "base/mem_map.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 25 | #include "class_linker.h" |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 26 | #include "common_compiler_test.h" |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 27 | #include "compiler.h" |
David Sehr | 9e734c7 | 2018-01-04 17:56:19 -0800 | [diff] [blame] | 28 | #include "dex/dex_file.h" |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 29 | #include "gtest/gtest.h" |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 30 | #include "indirect_reference_table.h" |
Vladimir Marko | a3ad0cd | 2018-05-04 10:06:38 +0100 | [diff] [blame] | 31 | #include "jni/java_vm_ext.h" |
| 32 | #include "jni/jni_internal.h" |
Ian Rogers | 4f6ad8a | 2013-03-18 15:27:28 -0700 | [diff] [blame] | 33 | #include "mirror/class-inl.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 34 | #include "mirror/class_loader.h" |
Ian Rogers | 04d7aa9 | 2013-03-16 14:29:17 -0700 | [diff] [blame] | 35 | #include "mirror/object-inl.h" |
Steven Moreland | e431e27 | 2017-07-18 16:53:49 -0700 | [diff] [blame] | 36 | #include "mirror/object_array-inl.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 37 | #include "mirror/stack_trace_element.h" |
Steven Moreland | e431e27 | 2017-07-18 16:53:49 -0700 | [diff] [blame] | 38 | #include "nativehelper/ScopedLocalRef.h" |
Dimitry Ivanov | 5edb063 | 2016-04-29 11:14:25 -0700 | [diff] [blame] | 39 | #include "nativeloader/native_loader.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 40 | #include "runtime.h" |
Mathieu Chartier | 0795f23 | 2016-09-27 18:43:30 -0700 | [diff] [blame] | 41 | #include "scoped_thread_state_change-inl.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 42 | #include "thread.h" |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 43 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 44 | extern "C" JNIEXPORT jint JNICALL Java_MyClassNatives_bar(JNIEnv*, jobject, jint count) { |
Brian Carlstrom | b9cc1ca | 2012-01-27 00:57:42 -0800 | [diff] [blame] | 45 | return count + 1; |
| 46 | } |
| 47 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 48 | extern "C" JNIEXPORT jint JNICALL Java_MyClassNatives_sbar(JNIEnv*, jclass, jint count) { |
Ian Rogers | 1cefdbd | 2012-02-29 09:34:50 -0800 | [diff] [blame] | 49 | return count + 1; |
| 50 | } |
| 51 | |
Roland Levillain | 97c4646 | 2017-05-11 14:04:03 +0100 | [diff] [blame] | 52 | // TODO: In the Baker read barrier configuration, add checks to ensure |
| 53 | // the Marking Register's value is correct. |
| 54 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 55 | namespace art { |
| 56 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 57 | enum class JniKind { |
Vladimir Marko | b0a6aee | 2017-10-27 10:34:04 +0100 | [diff] [blame] | 58 | kNormal, // Regular kind of un-annotated natives. |
| 59 | kFast, // Native method annotated with @FastNative. |
| 60 | kCritical, // Native method annotated with @CriticalNative. |
| 61 | kCount // How many different types of JNIs we can have. |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | // Used to initialize array sizes that want to have different state per current jni. |
| 65 | static constexpr size_t kJniKindCount = static_cast<size_t>(JniKind::kCount); |
| 66 | // Do not use directly, use the helpers instead. |
| 67 | uint32_t gCurrentJni = static_cast<uint32_t>(JniKind::kNormal); |
| 68 | |
| 69 | // Is the current native method under test @CriticalNative? |
| 70 | static bool IsCurrentJniCritical() { |
| 71 | return gCurrentJni == static_cast<uint32_t>(JniKind::kCritical); |
| 72 | } |
| 73 | |
| 74 | // Is the current native method a plain-old non-annotated native? |
| 75 | static bool IsCurrentJniNormal() { |
| 76 | return gCurrentJni == static_cast<uint32_t>(JniKind::kNormal); |
| 77 | } |
| 78 | |
Roland Levillain | ef01222 | 2017-06-21 16:28:06 +0100 | [diff] [blame] | 79 | // Signify that a different kind of JNI is about to be tested. |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 80 | static void UpdateCurrentJni(JniKind kind) { |
| 81 | gCurrentJni = static_cast<uint32_t>(kind); |
| 82 | } |
| 83 | |
| 84 | // (Match the name suffixes of native methods in MyClassNatives.java) |
| 85 | static std::string CurrentJniStringSuffix() { |
| 86 | switch (gCurrentJni) { |
| 87 | case static_cast<uint32_t>(JniKind::kNormal): { |
| 88 | return ""; |
| 89 | } |
| 90 | case static_cast<uint32_t>(JniKind::kFast): { |
| 91 | return "_Fast"; |
| 92 | } |
| 93 | case static_cast<uint32_t>(JniKind::kCritical): { |
| 94 | return "_Critical"; |
| 95 | } |
| 96 | default: |
| 97 | LOG(FATAL) << "Invalid current JNI value: " << gCurrentJni; |
| 98 | UNREACHABLE(); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // Dummy values passed to our JNI handlers when we enter @CriticalNative. |
| 103 | // Normally @CriticalNative calling convention strips out the "JNIEnv*, jclass" parameters. |
| 104 | // However to avoid duplicating every single test method we have a templated handler |
| 105 | // that inserts dummy parameters (0,1) to make it compatible with a regular JNI handler. |
| 106 | static JNIEnv* const kCriticalDummyJniEnv = reinterpret_cast<JNIEnv*>(0xDEADFEAD); |
| 107 | static jclass const kCriticalDummyJniClass = reinterpret_cast<jclass>(0xBEAFBEEF); |
| 108 | |
| 109 | // Type trait. Returns true if "T" is the same type as one of the types in Args... |
| 110 | // |
| 111 | // Logically equal to OR(std::same_type<T, U> for all U in Args). |
| 112 | template <typename T, typename ... Args> |
| 113 | struct is_any_of; |
| 114 | |
| 115 | template <typename T, typename U, typename ... Args> |
| 116 | struct is_any_of<T, U, Args ...> { |
| 117 | using value_type = bool; |
| 118 | static constexpr const bool value = std::is_same<T, U>::value || is_any_of<T, Args ...>::value; |
| 119 | }; |
| 120 | |
| 121 | template <typename T, typename U> |
| 122 | struct is_any_of<T, U> { |
| 123 | using value_type = bool; |
| 124 | static constexpr const bool value = std::is_same<T, U>::value; |
| 125 | }; |
| 126 | |
| 127 | // Type traits for JNI types. |
| 128 | template <typename T> |
| 129 | struct jni_type_traits { |
| 130 | // True if type T ends up holding an object reference. False otherwise. |
| 131 | // (Non-JNI types will also be false). |
| 132 | static constexpr const bool is_ref = |
| 133 | is_any_of<T, jclass, jobject, jstring, jobjectArray, jintArray, |
| 134 | jcharArray, jfloatArray, jshortArray, jdoubleArray, jlongArray>::value; |
| 135 | }; |
| 136 | |
| 137 | template <typename ... Args> |
| 138 | struct count_refs_helper { |
| 139 | using value_type = size_t; |
| 140 | static constexpr const size_t value = 0; |
| 141 | }; |
| 142 | |
| 143 | template <typename Arg, typename ... Args> |
| 144 | struct count_refs_helper<Arg, Args ...> { |
| 145 | using value_type = size_t; |
| 146 | static constexpr size_t value = |
| 147 | (jni_type_traits<Arg>::is_ref ? 1 : 0) + count_refs_helper<Args ...>::value; |
| 148 | }; |
| 149 | |
| 150 | template <typename T, T fn> |
| 151 | struct count_refs_fn_helper; |
| 152 | |
| 153 | template <typename R, typename ... Args, R fn(Args...)> |
| 154 | struct count_refs_fn_helper<R(Args...), fn> : public count_refs_helper<Args...> {}; |
| 155 | |
| 156 | // Given a function type 'T' figure out how many of the parameter types are a reference. |
| 157 | // -- The implicit jclass and thisObject also count as 1 reference. |
| 158 | // |
| 159 | // Fields: |
| 160 | // * value - the result counting # of refs |
| 161 | // * value_type - the type of value (size_t) |
| 162 | template <typename T, T fn> |
| 163 | struct count_refs : public count_refs_fn_helper<T, fn> {}; |
| 164 | |
| 165 | // Base case: No parameters = 0 refs. |
| 166 | size_t count_nonnull_refs_helper() { |
| 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | // SFINAE for ref types. 1 if non-null, 0 otherwise. |
| 171 | template <typename T> |
| 172 | size_t count_nonnull_refs_single_helper(T arg, |
| 173 | typename std::enable_if<jni_type_traits<T>::is_ref>::type* |
| 174 | = nullptr) { |
| 175 | return ((arg == NULL) ? 0 : 1); |
| 176 | } |
| 177 | |
| 178 | // SFINAE for non-ref-types. Always 0. |
| 179 | template <typename T> |
| 180 | size_t count_nonnull_refs_single_helper(T arg ATTRIBUTE_UNUSED, |
| 181 | typename std::enable_if<!jni_type_traits<T>::is_ref>::type* |
| 182 | = nullptr) { |
| 183 | return 0; |
| 184 | } |
| 185 | |
| 186 | // Recursive case. |
| 187 | template <typename T, typename ... Args> |
| 188 | size_t count_nonnull_refs_helper(T arg, Args ... args) { |
| 189 | return count_nonnull_refs_single_helper(arg) + count_nonnull_refs_helper(args...); |
| 190 | } |
| 191 | |
| 192 | // Given any list of parameters, check how many object refs there are and only count |
| 193 | // them if their runtime value is non-null. |
| 194 | // |
| 195 | // For example given (jobject, jint, jclass) we can get (2) if both #0/#2 are non-null, |
| 196 | // (1) if either #0/#2 are null but not both, and (0) if all parameters are null. |
| 197 | // Primitive parameters (including JNIEnv*, if present) are ignored. |
| 198 | template <typename ... Args> |
| 199 | size_t count_nonnull_refs(Args ... args) { |
| 200 | return count_nonnull_refs_helper(args...); |
| 201 | } |
| 202 | |
| 203 | template <typename T, T fn> |
| 204 | struct remove_extra_parameters_helper; |
| 205 | |
| 206 | template <typename R, typename Arg1, typename Arg2, typename ... Args, R fn(Arg1, Arg2, Args...)> |
| 207 | struct remove_extra_parameters_helper<R(Arg1, Arg2, Args...), fn> { |
| 208 | // Note: Do not use Args&& here to maintain C-style parameter types. |
| 209 | static R apply(Args... args) { |
| 210 | JNIEnv* env = kCriticalDummyJniEnv; |
| 211 | jclass kls = kCriticalDummyJniClass; |
| 212 | return fn(env, kls, args...); |
| 213 | } |
| 214 | }; |
| 215 | |
| 216 | // Given a function 'fn' create a function 'apply' which will omit the JNIEnv/jklass parameters |
| 217 | // |
| 218 | // i.e. if fn(JNIEnv*,jklass,a,b,c,d,e...) then apply(a,b,c,d,e,...) |
| 219 | template <typename T, T fn> |
| 220 | struct jni_remove_extra_parameters : public remove_extra_parameters_helper<T, fn> {}; |
| 221 | |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 222 | class JniCompilerTest : public CommonCompilerTest { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 223 | protected: |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 224 | void SetUp() override { |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 225 | CommonCompilerTest::SetUp(); |
| 226 | check_generic_jni_ = false; |
| 227 | } |
| 228 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 229 | void TearDown() override { |
Dimitry Ivanov | 5edb063 | 2016-04-29 11:14:25 -0700 | [diff] [blame] | 230 | android::ResetNativeLoader(); |
| 231 | CommonCompilerTest::TearDown(); |
| 232 | } |
| 233 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 234 | void SetCheckGenericJni(bool generic) { |
| 235 | check_generic_jni_ = generic; |
| 236 | } |
| 237 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 238 | private: |
| 239 | void CompileForTest(jobject class_loader, |
| 240 | bool direct, |
| 241 | const char* method_name, |
| 242 | const char* method_sig) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 243 | ScopedObjectAccess soa(Thread::Current()); |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 244 | StackHandleScope<1> hs(soa.Self()); |
| 245 | Handle<mirror::ClassLoader> loader( |
Mathieu Chartier | 0795f23 | 2016-09-27 18:43:30 -0700 | [diff] [blame] | 246 | hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader))); |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 247 | // Compile the native method before starting the runtime |
Vladimir Marko | e9987b0 | 2018-05-22 16:26:43 +0100 | [diff] [blame] | 248 | ObjPtr<mirror::Class> c = class_linker_->FindClass(soa.Self(), "LMyClassNatives;", loader); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 249 | const auto pointer_size = class_linker_->GetImagePointerSize(); |
Vladimir Marko | ba11882 | 2017-06-12 15:41:56 +0100 | [diff] [blame] | 250 | ArtMethod* method = c->FindClassMethod(method_name, method_sig, pointer_size); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 251 | ASSERT_TRUE(method != nullptr) << method_name << " " << method_sig; |
Vladimir Marko | ba11882 | 2017-06-12 15:41:56 +0100 | [diff] [blame] | 252 | ASSERT_EQ(direct, method->IsDirect()) << method_name << " " << method_sig; |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 253 | if (check_generic_jni_) { |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 254 | method->SetEntryPointFromQuickCompiledCode(class_linker_->GetRuntimeQuickGenericJniStub()); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 255 | } else { |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 256 | const void* code = method->GetEntryPointFromQuickCompiledCode(); |
| 257 | if (code == nullptr || class_linker_->IsQuickGenericJniStub(code)) { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 258 | CompileMethod(method); |
| 259 | ASSERT_TRUE(method->GetEntryPointFromQuickCompiledCode() != nullptr) |
| 260 | << method_name << " " << method_sig; |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 261 | } |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 262 | } |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 263 | } |
| 264 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 265 | protected: |
| 266 | void CompileForTestWithCurrentJni(jobject class_loader, |
| 267 | bool direct, |
| 268 | const char* method_name_orig, |
| 269 | const char* method_sig) { |
| 270 | // Append the JNI kind to the method name, so that we automatically get the |
| 271 | // fast or critical versions of the same method. |
| 272 | std::string method_name_str = std::string(method_name_orig) + CurrentJniStringSuffix(); |
| 273 | const char* method_name = method_name_str.c_str(); |
| 274 | |
| 275 | CompileForTest(class_loader, direct, method_name, method_sig); |
| 276 | } |
| 277 | |
| 278 | void SetUpForTest(bool direct, |
| 279 | const char* method_name_orig, |
| 280 | const char* method_sig, |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 281 | void* native_fnptr) { |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 282 | // Append the JNI kind to the method name, so that we automatically get the |
| 283 | // fast or critical versions of the same method. |
| 284 | std::string method_name_str = std::string(method_name_orig) + CurrentJniStringSuffix(); |
| 285 | const char* method_name = method_name_str.c_str(); |
| 286 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 287 | // Initialize class loader and compile method when runtime not started. |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 288 | if (!runtime_->IsStarted()) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 289 | { |
| 290 | ScopedObjectAccess soa(Thread::Current()); |
| 291 | class_loader_ = LoadDex("MyClassNatives"); |
| 292 | } |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 293 | CompileForTest(class_loader_, direct, method_name, method_sig); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 294 | // Start runtime. |
| 295 | Thread::Current()->TransitionFromSuspendedToRunnable(); |
Dimitry Ivanov | 5edb063 | 2016-04-29 11:14:25 -0700 | [diff] [blame] | 296 | android::InitializeNativeLoader(); |
Dimitry Ivanov | c544f34 | 2016-05-09 16:26:13 -0700 | [diff] [blame] | 297 | bool started = runtime_->Start(); |
Brian Carlstrom | bd86bcc | 2013-03-10 20:26:16 -0700 | [diff] [blame] | 298 | CHECK(started); |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 299 | } |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 300 | // JNI operations after runtime start. |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 301 | env_ = Thread::Current()->GetJniEnv(); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 302 | jklass_ = env_->FindClass("MyClassNatives"); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 303 | ASSERT_TRUE(jklass_ != nullptr) << method_name << " " << method_sig; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 304 | |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 305 | if (direct) { |
| 306 | jmethod_ = env_->GetStaticMethodID(jklass_, method_name, method_sig); |
| 307 | } else { |
| 308 | jmethod_ = env_->GetMethodID(jklass_, method_name, method_sig); |
| 309 | } |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 310 | ASSERT_TRUE(jmethod_ != nullptr) << method_name << " " << method_sig; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 311 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 312 | if (native_fnptr != nullptr) { |
Elliott Hughes | b25c3f6 | 2012-03-26 16:35:06 -0700 | [diff] [blame] | 313 | JNINativeMethod methods[] = { { method_name, method_sig, native_fnptr } }; |
Brian Carlstrom | fc7120c | 2012-08-27 13:43:25 -0700 | [diff] [blame] | 314 | ASSERT_EQ(JNI_OK, env_->RegisterNatives(jklass_, methods, 1)) |
| 315 | << method_name << " " << method_sig; |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 316 | } else { |
| 317 | env_->UnregisterNatives(jklass_); |
Shih-wei Liao | 31384c5 | 2011-09-06 15:27:45 -0700 | [diff] [blame] | 318 | } |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 319 | |
| 320 | jmethodID constructor = env_->GetMethodID(jklass_, "<init>", "()V"); |
| 321 | jobj_ = env_->NewObject(jklass_, constructor); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 322 | ASSERT_TRUE(jobj_ != nullptr) << method_name << " " << method_sig; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 323 | } |
| 324 | |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 325 | public: |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 326 | // Available as statics so our JNI handlers can access these. |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 327 | static jclass jklass_; |
| 328 | static jobject jobj_; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 329 | static jobject class_loader_; |
| 330 | |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 331 | protected: |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 332 | // We have to list the methods here so we can share them between default and generic JNI. |
| 333 | void CompileAndRunNoArgMethodImpl(); |
| 334 | void CompileAndRunIntMethodThroughStubImpl(); |
| 335 | void CompileAndRunStaticIntMethodThroughStubImpl(); |
| 336 | void CompileAndRunIntMethodImpl(); |
| 337 | void CompileAndRunIntIntMethodImpl(); |
| 338 | void CompileAndRunLongLongMethodImpl(); |
| 339 | void CompileAndRunDoubleDoubleMethodImpl(); |
| 340 | void CompileAndRun_fooJJ_synchronizedImpl(); |
| 341 | void CompileAndRunIntObjectObjectMethodImpl(); |
| 342 | void CompileAndRunStaticIntIntMethodImpl(); |
| 343 | void CompileAndRunStaticDoubleDoubleMethodImpl(); |
| 344 | void RunStaticLogDoubleMethodImpl(); |
| 345 | void RunStaticLogFloatMethodImpl(); |
| 346 | void RunStaticReturnTrueImpl(); |
| 347 | void RunStaticReturnFalseImpl(); |
| 348 | void RunGenericStaticReturnIntImpl(); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 349 | void RunGenericStaticReturnDoubleImpl(); |
| 350 | void RunGenericStaticReturnLongImpl(); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 351 | void CompileAndRunStaticIntObjectObjectMethodImpl(); |
| 352 | void CompileAndRunStaticSynchronizedIntObjectObjectMethodImpl(); |
| 353 | void ExceptionHandlingImpl(); |
| 354 | void NativeStackTraceElementImpl(); |
| 355 | void ReturnGlobalRefImpl(); |
| 356 | void LocalReferenceTableClearingTestImpl(); |
| 357 | void JavaLangSystemArrayCopyImpl(); |
| 358 | void CompareAndSwapIntImpl(); |
| 359 | void GetTextImpl(); |
| 360 | void GetSinkPropertiesNativeImpl(); |
| 361 | void UpcallReturnTypeChecking_InstanceImpl(); |
| 362 | void UpcallReturnTypeChecking_StaticImpl(); |
| 363 | void UpcallArgumentTypeChecking_InstanceImpl(); |
| 364 | void UpcallArgumentTypeChecking_StaticImpl(); |
| 365 | void CompileAndRunFloatFloatMethodImpl(); |
| 366 | void CheckParameterAlignImpl(); |
| 367 | void MaxParamNumberImpl(); |
| 368 | void WithoutImplementationImpl(); |
Andreas Gampe | 48ee356 | 2015-04-10 19:57:29 -0700 | [diff] [blame] | 369 | void WithoutImplementationRefReturnImpl(); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 370 | void StackArgsIntsFirstImpl(); |
| 371 | void StackArgsFloatsFirstImpl(); |
| 372 | void StackArgsMixedImpl(); |
Pavle Batuta | 837e72a | 2016-03-16 11:31:46 +0100 | [diff] [blame] | 373 | #if defined(__mips__) && defined(__LP64__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) |
Lazar Trsic | f652d60 | 2015-06-24 16:30:21 +0200 | [diff] [blame] | 374 | void StackArgsSignExtendedMips64Impl(); |
Pavle Batuta | 837e72a | 2016-03-16 11:31:46 +0100 | [diff] [blame] | 375 | #endif |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 376 | |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 377 | void NormalNativeImpl(); |
| 378 | void FastNativeImpl(); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 379 | void CriticalNativeImpl(); |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 380 | |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 381 | JNIEnv* env_; |
| 382 | jmethodID jmethod_; |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 383 | |
| 384 | private: |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 385 | bool check_generic_jni_; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 386 | }; |
| 387 | |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 388 | jclass JniCompilerTest::jklass_; |
| 389 | jobject JniCompilerTest::jobj_; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 390 | jobject JniCompilerTest::class_loader_; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 391 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 392 | // Test the normal compiler and normal generic JNI only. |
| 393 | // The following features are unsupported in @FastNative: |
| 394 | // 1) JNI stubs (lookup via dlsym) when methods aren't explicitly registered |
Igor Murashkin | af1e299 | 2016-10-12 17:44:50 -0700 | [diff] [blame] | 395 | // 2) synchronized keyword |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 396 | // -- TODO: We can support (1) if we remove the mutator lock assert during stub lookup. |
| 397 | # define JNI_TEST_NORMAL_ONLY(TestName) \ |
Igor Murashkin | 06a04e0 | 2016-09-13 15:57:37 -0700 | [diff] [blame] | 398 | TEST_F(JniCompilerTest, TestName ## NormalCompiler) { \ |
Igor Murashkin | a51d8b7 | 2016-10-05 14:33:30 -0700 | [diff] [blame] | 399 | ScopedCheckHandleScope top_handle_scope_check; \ |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 400 | SCOPED_TRACE("Normal JNI with compiler"); \ |
| 401 | gCurrentJni = static_cast<uint32_t>(JniKind::kNormal); \ |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 402 | TestName ## Impl(); \ |
| 403 | } \ |
Igor Murashkin | 06a04e0 | 2016-09-13 15:57:37 -0700 | [diff] [blame] | 404 | TEST_F(JniCompilerTest, TestName ## NormalGeneric) { \ |
Igor Murashkin | a51d8b7 | 2016-10-05 14:33:30 -0700 | [diff] [blame] | 405 | ScopedCheckHandleScope top_handle_scope_check; \ |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 406 | SCOPED_TRACE("Normal JNI with generic"); \ |
| 407 | gCurrentJni = static_cast<uint32_t>(JniKind::kNormal); \ |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 408 | SetCheckGenericJni(true); \ |
| 409 | TestName ## Impl(); \ |
| 410 | } |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 411 | |
Igor Murashkin | 06a04e0 | 2016-09-13 15:57:37 -0700 | [diff] [blame] | 412 | // Test (normal, @FastNative) x (compiler, generic). |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 413 | #define JNI_TEST(TestName) \ |
| 414 | JNI_TEST_NORMAL_ONLY(TestName) \ |
Igor Murashkin | 06a04e0 | 2016-09-13 15:57:37 -0700 | [diff] [blame] | 415 | TEST_F(JniCompilerTest, TestName ## FastCompiler) { \ |
Igor Murashkin | a51d8b7 | 2016-10-05 14:33:30 -0700 | [diff] [blame] | 416 | ScopedCheckHandleScope top_handle_scope_check; \ |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 417 | SCOPED_TRACE("@FastNative JNI with compiler"); \ |
| 418 | gCurrentJni = static_cast<uint32_t>(JniKind::kFast); \ |
| 419 | TestName ## Impl(); \ |
| 420 | } \ |
Igor Murashkin | 06a04e0 | 2016-09-13 15:57:37 -0700 | [diff] [blame] | 421 | \ |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 422 | TEST_F(JniCompilerTest, TestName ## FastGeneric) { \ |
Igor Murashkin | a51d8b7 | 2016-10-05 14:33:30 -0700 | [diff] [blame] | 423 | ScopedCheckHandleScope top_handle_scope_check; \ |
Igor Murashkin | 06a04e0 | 2016-09-13 15:57:37 -0700 | [diff] [blame] | 424 | SCOPED_TRACE("@FastNative JNI with generic"); \ |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 425 | gCurrentJni = static_cast<uint32_t>(JniKind::kFast); \ |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 426 | SetCheckGenericJni(true); \ |
| 427 | TestName ## Impl(); \ |
| 428 | } |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 429 | |
Igor Murashkin | 06a04e0 | 2016-09-13 15:57:37 -0700 | [diff] [blame] | 430 | // Test (@CriticalNative) x (compiler, generic) only. |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 431 | #define JNI_TEST_CRITICAL_ONLY(TestName) \ |
Igor Murashkin | 06a04e0 | 2016-09-13 15:57:37 -0700 | [diff] [blame] | 432 | TEST_F(JniCompilerTest, TestName ## CriticalCompiler) { \ |
Igor Murashkin | a51d8b7 | 2016-10-05 14:33:30 -0700 | [diff] [blame] | 433 | ScopedCheckHandleScope top_handle_scope_check; \ |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 434 | SCOPED_TRACE("@CriticalNative JNI with compiler"); \ |
| 435 | gCurrentJni = static_cast<uint32_t>(JniKind::kCritical); \ |
| 436 | TestName ## Impl(); \ |
Igor Murashkin | 06a04e0 | 2016-09-13 15:57:37 -0700 | [diff] [blame] | 437 | } \ |
| 438 | TEST_F(JniCompilerTest, TestName ## CriticalGeneric) { \ |
Igor Murashkin | a51d8b7 | 2016-10-05 14:33:30 -0700 | [diff] [blame] | 439 | ScopedCheckHandleScope top_handle_scope_check; \ |
Igor Murashkin | 06a04e0 | 2016-09-13 15:57:37 -0700 | [diff] [blame] | 440 | SCOPED_TRACE("@CriticalNative JNI with generic"); \ |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 441 | gCurrentJni = static_cast<uint32_t>(JniKind::kCritical); \ |
Igor Murashkin | 294a915 | 2016-09-28 13:23:19 -0700 | [diff] [blame] | 442 | SetCheckGenericJni(true); \ |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 443 | TestName ## Impl(); \ |
| 444 | } |
Igor Murashkin | 06a04e0 | 2016-09-13 15:57:37 -0700 | [diff] [blame] | 445 | |
| 446 | // Test everything: (normal, @FastNative, @CriticalNative) x (compiler, generic). |
| 447 | #define JNI_TEST_CRITICAL(TestName) \ |
| 448 | JNI_TEST(TestName) \ |
| 449 | JNI_TEST_CRITICAL_ONLY(TestName) \ |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 450 | |
| 451 | static void expectValidThreadState() { |
| 452 | // Normal JNI always transitions to "Native". Other JNIs stay in the "Runnable" state. |
| 453 | if (IsCurrentJniNormal()) { |
| 454 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
| 455 | } else { |
| 456 | EXPECT_EQ(kRunnable, Thread::Current()->GetState()); |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | #define EXPECT_THREAD_STATE_FOR_CURRENT_JNI() expectValidThreadState() |
| 461 | |
| 462 | static void expectValidMutatorLockHeld() { |
| 463 | if (IsCurrentJniNormal()) { |
| 464 | Locks::mutator_lock_->AssertNotHeld(Thread::Current()); |
| 465 | } else { |
| 466 | Locks::mutator_lock_->AssertSharedHeld(Thread::Current()); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | #define EXPECT_MUTATOR_LOCK_FOR_CURRENT_JNI() expectValidMutatorLockHeld() |
| 471 | |
| 472 | static void expectValidJniEnvAndObject(JNIEnv* env, jobject thisObj) { |
| 473 | if (!IsCurrentJniCritical()) { |
| 474 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
| 475 | ASSERT_TRUE(thisObj != nullptr); |
| 476 | EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_)); |
| 477 | } else { |
| 478 | LOG(FATAL) << "Objects are not supported for @CriticalNative, why is this being tested?"; |
| 479 | UNREACHABLE(); |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | // Validates the JNIEnv to be the same as the current thread's JNIEnv, and makes sure |
| 484 | // that the object here is an instance of the class we registered the method with. |
| 485 | // |
| 486 | // Hard-fails if this somehow gets invoked for @CriticalNative since objects are unsupported. |
| 487 | #define EXPECT_JNI_ENV_AND_OBJECT_FOR_CURRENT_JNI(env, thisObj) \ |
| 488 | expectValidJniEnvAndObject(env, thisObj) |
| 489 | |
| 490 | static void expectValidJniEnvAndClass(JNIEnv* env, jclass kls) { |
| 491 | if (!IsCurrentJniCritical()) { |
| 492 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
| 493 | ASSERT_TRUE(kls != nullptr); |
| 494 | EXPECT_TRUE(env->IsSameObject(static_cast<jobject>(JniCompilerTest::jklass_), |
| 495 | static_cast<jobject>(kls))); |
| 496 | } else { |
| 497 | // This is pretty much vacuously true but catch any testing setup mistakes. |
| 498 | EXPECT_EQ(env, kCriticalDummyJniEnv); |
| 499 | EXPECT_EQ(kls, kCriticalDummyJniClass); |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | // Validates the JNIEnv is the same as the current thread's JNIenv, and makes sure |
| 504 | // that the jclass we got in the JNI handler is the same one as the class the method was looked |
| 505 | // up for. |
| 506 | // |
| 507 | // (Checks are skipped for @CriticalNative since the two values are dummy). |
| 508 | #define EXPECT_JNI_ENV_AND_CLASS_FOR_CURRENT_JNI(env, kls) expectValidJniEnvAndClass(env, kls) |
| 509 | |
| 510 | // Temporarily disable the EXPECT_NUM_STACK_REFERENCES check (for a single test). |
| 511 | struct ScopedDisableCheckNumStackReferences { |
| 512 | ScopedDisableCheckNumStackReferences() { |
Igor Murashkin | 06a04e0 | 2016-09-13 15:57:37 -0700 | [diff] [blame] | 513 | CHECK(sCheckNumStackReferences); // No nested support. |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 514 | sCheckNumStackReferences = false; |
| 515 | } |
| 516 | |
| 517 | ~ScopedDisableCheckNumStackReferences() { |
| 518 | sCheckNumStackReferences = true; |
| 519 | } |
| 520 | |
| 521 | static bool sCheckNumStackReferences; |
| 522 | }; |
| 523 | |
| 524 | bool ScopedDisableCheckNumStackReferences::sCheckNumStackReferences = true; |
| 525 | |
Roland Levillain | 2ae376f | 2018-01-30 11:35:11 +0000 | [diff] [blame] | 526 | // Check that the handle scope at the start of this block is the same |
| 527 | // as the handle scope at the end of the block. |
Igor Murashkin | a51d8b7 | 2016-10-05 14:33:30 -0700 | [diff] [blame] | 528 | struct ScopedCheckHandleScope { |
Igor Murashkin | 4229811 | 2016-10-06 10:51:11 -0700 | [diff] [blame] | 529 | ScopedCheckHandleScope() : handle_scope_(Thread::Current()->GetTopHandleScope()) { |
Igor Murashkin | a51d8b7 | 2016-10-05 14:33:30 -0700 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | ~ScopedCheckHandleScope() { |
| 533 | EXPECT_EQ(handle_scope_, Thread::Current()->GetTopHandleScope()) |
| 534 | << "Top-most handle scope must be the same after all the JNI " |
| 535 | << "invocations have finished (as before they were invoked)."; |
| 536 | } |
| 537 | |
Mathieu Chartier | e8a3c57 | 2016-10-11 16:52:17 -0700 | [diff] [blame] | 538 | BaseHandleScope* const handle_scope_; |
Igor Murashkin | a51d8b7 | 2016-10-05 14:33:30 -0700 | [diff] [blame] | 539 | }; |
| 540 | |
Andreas Gampe | 0a85576 | 2016-10-26 13:43:14 -0700 | [diff] [blame] | 541 | // Number of references allocated in JNI ShadowFrames on the given thread. |
| 542 | static size_t NumJniShadowFrameReferences(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) { |
| 543 | return self->GetManagedStack()->NumJniShadowFrameReferences(); |
| 544 | } |
| 545 | |
| 546 | // Number of references in handle scope on the given thread. |
| 547 | static size_t NumHandleReferences(Thread* self) { |
| 548 | size_t count = 0; |
| 549 | for (BaseHandleScope* cur = self->GetTopHandleScope(); cur != nullptr; cur = cur->GetLink()) { |
| 550 | count += cur->NumberOfReferences(); |
| 551 | } |
| 552 | return count; |
| 553 | } |
| 554 | |
| 555 | // Number of references allocated in handle scopes & JNI shadow frames on this thread. |
| 556 | static size_t NumStackReferences(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) { |
| 557 | return NumHandleReferences(self) + NumJniShadowFrameReferences(self); |
| 558 | } |
| 559 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 560 | static void expectNumStackReferences(size_t val1, size_t val2) { |
| 561 | // In rare cases when JNI functions call themselves recursively, |
| 562 | // disable this test because it will have a false negative. |
| 563 | if (!IsCurrentJniCritical() && ScopedDisableCheckNumStackReferences::sCheckNumStackReferences) { |
| 564 | /* @CriticalNative doesn't build a HandleScope, so this test is meaningless then. */ |
| 565 | ScopedObjectAccess soa(Thread::Current()); |
| 566 | |
Andreas Gampe | 0a85576 | 2016-10-26 13:43:14 -0700 | [diff] [blame] | 567 | size_t actual_num = NumStackReferences(Thread::Current()); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 568 | // XX: Not too sure what's going on. |
| 569 | // Sometimes null references get placed and sometimes they don't? |
| 570 | EXPECT_TRUE(val1 == actual_num || val2 == actual_num) |
| 571 | << "expected either " << val1 << " or " << val2 |
| 572 | << " number of stack references, but got: " << actual_num; |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | #define EXPECT_NUM_STACK_REFERENCES(val1, val2) expectNumStackReferences(val1, val2) |
| 577 | |
| 578 | template <typename T, T fn> |
| 579 | struct make_jni_test_decorator; |
| 580 | |
| 581 | // Decorator for "static" JNI callbacks. |
| 582 | template <typename R, typename ... Args, R fn(JNIEnv*, jclass, Args...)> |
| 583 | struct make_jni_test_decorator<R(JNIEnv*, jclass kls, Args...), fn> { |
| 584 | static R apply(JNIEnv* env, jclass kls, Args ... args) { |
| 585 | EXPECT_THREAD_STATE_FOR_CURRENT_JNI(); |
| 586 | EXPECT_MUTATOR_LOCK_FOR_CURRENT_JNI(); |
| 587 | EXPECT_JNI_ENV_AND_CLASS_FOR_CURRENT_JNI(env, kls); |
| 588 | // All incoming parameters + the jclass get put into the transition's StackHandleScope. |
| 589 | EXPECT_NUM_STACK_REFERENCES(count_nonnull_refs(kls, args...), |
| 590 | (count_refs_helper<jclass, Args...>::value)); |
| 591 | |
| 592 | return fn(env, kls, args...); |
| 593 | } |
| 594 | }; |
| 595 | |
| 596 | // Decorator for instance JNI callbacks. |
| 597 | template <typename R, typename ... Args, R fn(JNIEnv*, jobject, Args...)> |
| 598 | struct make_jni_test_decorator<R(JNIEnv*, jobject, Args...), fn> { |
| 599 | static R apply(JNIEnv* env, jobject thisObj, Args ... args) { |
| 600 | EXPECT_THREAD_STATE_FOR_CURRENT_JNI(); |
| 601 | EXPECT_MUTATOR_LOCK_FOR_CURRENT_JNI(); |
| 602 | EXPECT_JNI_ENV_AND_OBJECT_FOR_CURRENT_JNI(env, thisObj); |
| 603 | // All incoming parameters + the implicit 'this' get put into the transition's StackHandleScope. |
| 604 | EXPECT_NUM_STACK_REFERENCES(count_nonnull_refs(thisObj, args...), |
| 605 | (count_refs_helper<jobject, Args...>::value)); |
| 606 | |
| 607 | return fn(env, thisObj, args...); |
| 608 | } |
| 609 | }; |
| 610 | |
| 611 | // Decorate the regular JNI callee with the extra gtest checks. |
| 612 | // This way we can have common test logic for everything generic like checking if a lock is held, |
| 613 | // checking handle scope state, etc. |
| 614 | #define MAKE_JNI_TEST_DECORATOR(fn) make_jni_test_decorator<decltype(fn), (fn)>::apply |
| 615 | |
| 616 | // Convert function f(JNIEnv*,jclass,a,b,c,d...) into f2(a,b,c,d...) |
| 617 | // -- This way we don't have to write out each implementation twice for @CriticalNative. |
| 618 | #define JNI_CRITICAL_WRAPPER(func) jni_remove_extra_parameters<decltype(func), (func)>::apply |
| 619 | // Get a function pointer whose calling convention either matches a regular native |
| 620 | // or a critical native depending on which kind of jni is currently under test. |
| 621 | // -- This also has the benefit of genering a compile time error if the 'func' doesn't properly |
| 622 | // have JNIEnv and jclass parameters first. |
| 623 | #define CURRENT_JNI_WRAPPER(func) \ |
| 624 | (IsCurrentJniCritical() \ |
| 625 | ? reinterpret_cast<void*>(&JNI_CRITICAL_WRAPPER(MAKE_JNI_TEST_DECORATOR(func))) \ |
| 626 | : reinterpret_cast<void*>(&MAKE_JNI_TEST_DECORATOR(func))) |
| 627 | |
| 628 | // Do the opposite of the above. Do *not* wrap the function, instead just cast it to a void*. |
| 629 | // Only for "TEST_JNI_NORMAL_ONLY" configs, and it inserts a test assert to ensure this is the case. |
| 630 | #define NORMAL_JNI_ONLY_NOWRAP(func) \ |
| 631 | ({ ASSERT_TRUE(IsCurrentJniNormal()); reinterpret_cast<void*>(&(func)); }) |
| 632 | // Same as above, but with nullptr. When we want to test the stub functionality. |
| 633 | #define NORMAL_JNI_ONLY_NULLPTR \ |
| 634 | ({ ASSERT_TRUE(IsCurrentJniNormal()); nullptr; }) |
| 635 | |
| 636 | |
| 637 | int gJava_MyClassNatives_foo_calls[kJniKindCount] = {}; |
| 638 | void Java_MyClassNatives_foo(JNIEnv*, jobject) { |
| 639 | gJava_MyClassNatives_foo_calls[gCurrentJni]++; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 640 | } |
| 641 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 642 | void JniCompilerTest::CompileAndRunNoArgMethodImpl() { |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 643 | SetUpForTest(false, "foo", "()V", CURRENT_JNI_WRAPPER(Java_MyClassNatives_foo)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 644 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 645 | EXPECT_EQ(0, gJava_MyClassNatives_foo_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 646 | env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 647 | EXPECT_EQ(1, gJava_MyClassNatives_foo_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 648 | env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 649 | EXPECT_EQ(2, gJava_MyClassNatives_foo_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 650 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 651 | gJava_MyClassNatives_foo_calls[gCurrentJni] = 0; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 652 | } |
| 653 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 654 | JNI_TEST(CompileAndRunNoArgMethod) |
| 655 | |
| 656 | void JniCompilerTest::CompileAndRunIntMethodThroughStubImpl() { |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 657 | SetUpForTest(false, "bar", "(I)I", NORMAL_JNI_ONLY_NULLPTR); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 658 | // calling through stub will link with &Java_MyClassNatives_bar |
Shih-wei Liao | 31384c5 | 2011-09-06 15:27:45 -0700 | [diff] [blame] | 659 | |
Shih-wei Liao | 31384c5 | 2011-09-06 15:27:45 -0700 | [diff] [blame] | 660 | std::string reason; |
Dmitriy Ivanov | f5a3099 | 2015-11-11 14:18:55 -0800 | [diff] [blame] | 661 | ASSERT_TRUE(Runtime::Current()->GetJavaVM()-> |
Andreas Gampe | 473191c | 2017-12-28 16:55:31 -0800 | [diff] [blame] | 662 | LoadNativeLibrary(env_, "", class_loader_, &reason)) |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 663 | << reason; |
Shih-wei Liao | 31384c5 | 2011-09-06 15:27:45 -0700 | [diff] [blame] | 664 | |
| 665 | jint result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 24); |
| 666 | EXPECT_EQ(25, result); |
| 667 | } |
| 668 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 669 | // TODO: Support @FastNative and @CriticalNative through stubs. |
| 670 | JNI_TEST_NORMAL_ONLY(CompileAndRunIntMethodThroughStub) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 671 | |
| 672 | void JniCompilerTest::CompileAndRunStaticIntMethodThroughStubImpl() { |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 673 | SetUpForTest(true, "sbar", "(I)I", NORMAL_JNI_ONLY_NULLPTR); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 674 | // calling through stub will link with &Java_MyClassNatives_sbar |
Ian Rogers | 1cefdbd | 2012-02-29 09:34:50 -0800 | [diff] [blame] | 675 | |
| 676 | std::string reason; |
Dmitriy Ivanov | f5a3099 | 2015-11-11 14:18:55 -0800 | [diff] [blame] | 677 | ASSERT_TRUE(Runtime::Current()->GetJavaVM()-> |
Andreas Gampe | 473191c | 2017-12-28 16:55:31 -0800 | [diff] [blame] | 678 | LoadNativeLibrary(env_, "", class_loader_, &reason)) |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 679 | << reason; |
Ian Rogers | 1cefdbd | 2012-02-29 09:34:50 -0800 | [diff] [blame] | 680 | |
| 681 | jint result = env_->CallStaticIntMethod(jklass_, jmethod_, 42); |
| 682 | EXPECT_EQ(43, result); |
| 683 | } |
| 684 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 685 | // TODO: Support @FastNative and @CriticalNative through stubs. |
| 686 | JNI_TEST_NORMAL_ONLY(CompileAndRunStaticIntMethodThroughStub) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 687 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 688 | int gJava_MyClassNatives_fooI_calls[kJniKindCount] = {}; |
| 689 | jint Java_MyClassNatives_fooI(JNIEnv*, jobject, jint x) { |
| 690 | gJava_MyClassNatives_fooI_calls[gCurrentJni]++; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 691 | return x; |
| 692 | } |
| 693 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 694 | void JniCompilerTest::CompileAndRunIntMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 695 | SetUpForTest(false, "fooI", "(I)I", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 696 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooI)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 697 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 698 | EXPECT_EQ(0, gJava_MyClassNatives_fooI_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 699 | jint result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 42); |
| 700 | EXPECT_EQ(42, result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 701 | EXPECT_EQ(1, gJava_MyClassNatives_fooI_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 702 | result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 0xCAFED00D); |
| 703 | EXPECT_EQ(static_cast<jint>(0xCAFED00D), result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 704 | EXPECT_EQ(2, gJava_MyClassNatives_fooI_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 705 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 706 | gJava_MyClassNatives_fooI_calls[gCurrentJni] = 0; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 707 | } |
| 708 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 709 | JNI_TEST(CompileAndRunIntMethod) |
| 710 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 711 | int gJava_MyClassNatives_fooII_calls[kJniKindCount] = {}; |
| 712 | jint Java_MyClassNatives_fooII(JNIEnv*, jobject, jint x, jint y) { |
| 713 | gJava_MyClassNatives_fooII_calls[gCurrentJni]++; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 714 | return x - y; // non-commutative operator |
| 715 | } |
| 716 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 717 | void JniCompilerTest::CompileAndRunIntIntMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 718 | SetUpForTest(false, "fooII", "(II)I", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 719 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooII)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 720 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 721 | EXPECT_EQ(0, gJava_MyClassNatives_fooII_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 722 | jint result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 99, 10); |
| 723 | EXPECT_EQ(99 - 10, result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 724 | EXPECT_EQ(1, gJava_MyClassNatives_fooII_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 725 | result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 0xCAFEBABE, |
| 726 | 0xCAFED00D); |
| 727 | EXPECT_EQ(static_cast<jint>(0xCAFEBABE - 0xCAFED00D), result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 728 | EXPECT_EQ(2, gJava_MyClassNatives_fooII_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 729 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 730 | gJava_MyClassNatives_fooII_calls[gCurrentJni] = 0; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 731 | } |
| 732 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 733 | JNI_TEST(CompileAndRunIntIntMethod) |
| 734 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 735 | int gJava_MyClassNatives_fooJJ_calls[kJniKindCount] = {}; |
| 736 | jlong Java_MyClassNatives_fooJJ(JNIEnv*, jobject, jlong x, jlong y) { |
| 737 | gJava_MyClassNatives_fooJJ_calls[gCurrentJni]++; |
Ian Rogers | 9b269d2 | 2011-09-04 14:06:05 -0700 | [diff] [blame] | 738 | return x - y; // non-commutative operator |
| 739 | } |
| 740 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 741 | void JniCompilerTest::CompileAndRunLongLongMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 742 | SetUpForTest(false, "fooJJ", "(JJ)J", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 743 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooJJ)); |
Ian Rogers | 9b269d2 | 2011-09-04 14:06:05 -0700 | [diff] [blame] | 744 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 745 | EXPECT_EQ(0, gJava_MyClassNatives_fooJJ_calls[gCurrentJni]); |
Ian Rogers | 0f67847 | 2014-03-10 16:18:37 -0700 | [diff] [blame] | 746 | jlong a = INT64_C(0x1234567890ABCDEF); |
| 747 | jlong b = INT64_C(0xFEDCBA0987654321); |
Ian Rogers | 9b269d2 | 2011-09-04 14:06:05 -0700 | [diff] [blame] | 748 | jlong result = env_->CallNonvirtualLongMethod(jobj_, jklass_, jmethod_, a, b); |
| 749 | EXPECT_EQ(a - b, result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 750 | EXPECT_EQ(1, gJava_MyClassNatives_fooJJ_calls[gCurrentJni]); |
Ian Rogers | 9b269d2 | 2011-09-04 14:06:05 -0700 | [diff] [blame] | 751 | result = env_->CallNonvirtualLongMethod(jobj_, jklass_, jmethod_, b, a); |
| 752 | EXPECT_EQ(b - a, result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 753 | EXPECT_EQ(2, gJava_MyClassNatives_fooJJ_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 754 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 755 | gJava_MyClassNatives_fooJJ_calls[gCurrentJni] = 0; |
Ian Rogers | 9b269d2 | 2011-09-04 14:06:05 -0700 | [diff] [blame] | 756 | } |
| 757 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 758 | JNI_TEST(CompileAndRunLongLongMethod) |
| 759 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 760 | int gJava_MyClassNatives_fooDD_calls[kJniKindCount] = {}; |
| 761 | jdouble Java_MyClassNatives_fooDD(JNIEnv*, jobject, jdouble x, jdouble y) { |
| 762 | gJava_MyClassNatives_fooDD_calls[gCurrentJni]++; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 763 | return x - y; // non-commutative operator |
| 764 | } |
| 765 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 766 | void JniCompilerTest::CompileAndRunDoubleDoubleMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 767 | SetUpForTest(false, "fooDD", "(DD)D", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 768 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooDD)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 769 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 770 | EXPECT_EQ(0, gJava_MyClassNatives_fooDD_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 771 | jdouble result = env_->CallNonvirtualDoubleMethod(jobj_, jklass_, jmethod_, |
| 772 | 99.0, 10.0); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 773 | EXPECT_DOUBLE_EQ(99.0 - 10.0, result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 774 | EXPECT_EQ(1, gJava_MyClassNatives_fooDD_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 775 | jdouble a = 3.14159265358979323846; |
| 776 | jdouble b = 0.69314718055994530942; |
| 777 | result = env_->CallNonvirtualDoubleMethod(jobj_, jklass_, jmethod_, a, b); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 778 | EXPECT_DOUBLE_EQ(a - b, result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 779 | EXPECT_EQ(2, gJava_MyClassNatives_fooDD_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 780 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 781 | gJava_MyClassNatives_fooDD_calls[gCurrentJni] = 0; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 782 | } |
| 783 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 784 | int gJava_MyClassNatives_fooJJ_synchronized_calls[kJniKindCount] = {}; |
| 785 | jlong Java_MyClassNatives_fooJJ_synchronized(JNIEnv*, jobject, jlong x, jlong y) { |
| 786 | gJava_MyClassNatives_fooJJ_synchronized_calls[gCurrentJni]++; |
Elliott Hughes | 3e778f7 | 2012-05-21 15:29:52 -0700 | [diff] [blame] | 787 | return x | y; |
| 788 | } |
| 789 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 790 | void JniCompilerTest::CompileAndRun_fooJJ_synchronizedImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 791 | SetUpForTest(false, "fooJJ_synchronized", "(JJ)J", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 792 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooJJ_synchronized)); |
Elliott Hughes | 3e778f7 | 2012-05-21 15:29:52 -0700 | [diff] [blame] | 793 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 794 | EXPECT_EQ(0, gJava_MyClassNatives_fooJJ_synchronized_calls[gCurrentJni]); |
Elliott Hughes | 3e778f7 | 2012-05-21 15:29:52 -0700 | [diff] [blame] | 795 | jlong a = 0x1000000020000000ULL; |
| 796 | jlong b = 0x00ff000000aa0000ULL; |
| 797 | jlong result = env_->CallNonvirtualLongMethod(jobj_, jklass_, jmethod_, a, b); |
| 798 | EXPECT_EQ(a | b, result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 799 | EXPECT_EQ(1, gJava_MyClassNatives_fooJJ_synchronized_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 800 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 801 | gJava_MyClassNatives_fooJJ_synchronized_calls[gCurrentJni] = 0; |
Elliott Hughes | 3e778f7 | 2012-05-21 15:29:52 -0700 | [diff] [blame] | 802 | } |
| 803 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 804 | JNI_TEST_NORMAL_ONLY(CompileAndRun_fooJJ_synchronized) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 805 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 806 | int gJava_MyClassNatives_fooIOO_calls[kJniKindCount] = {}; |
| 807 | jobject Java_MyClassNatives_fooIOO(JNIEnv*, jobject thisObj, jint x, jobject y, |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 808 | jobject z) { |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 809 | gJava_MyClassNatives_fooIOO_calls[gCurrentJni]++; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 810 | switch (x) { |
| 811 | case 1: |
| 812 | return y; |
| 813 | case 2: |
| 814 | return z; |
| 815 | default: |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 816 | return thisObj; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 817 | } |
| 818 | } |
| 819 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 820 | void JniCompilerTest::CompileAndRunIntObjectObjectMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 821 | SetUpForTest(false, "fooIOO", |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 822 | "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 823 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooIOO)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 824 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 825 | EXPECT_EQ(0, gJava_MyClassNatives_fooIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 826 | jobject result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 0, nullptr, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 827 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 828 | EXPECT_EQ(1, gJava_MyClassNatives_fooIOO_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 829 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 830 | result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 0, nullptr, jklass_); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 831 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 832 | EXPECT_EQ(2, gJava_MyClassNatives_fooIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 833 | result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 1, nullptr, jklass_); |
| 834 | EXPECT_TRUE(env_->IsSameObject(nullptr, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 835 | EXPECT_EQ(3, gJava_MyClassNatives_fooIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 836 | result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 2, nullptr, jklass_); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 837 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 838 | EXPECT_EQ(4, gJava_MyClassNatives_fooIOO_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 839 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 840 | result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 0, jklass_, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 841 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 842 | EXPECT_EQ(5, gJava_MyClassNatives_fooIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 843 | result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 1, jklass_, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 844 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 845 | EXPECT_EQ(6, gJava_MyClassNatives_fooIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 846 | result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 2, jklass_, nullptr); |
| 847 | EXPECT_TRUE(env_->IsSameObject(nullptr, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 848 | EXPECT_EQ(7, gJava_MyClassNatives_fooIOO_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 849 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 850 | gJava_MyClassNatives_fooIOO_calls[gCurrentJni] = 0; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 851 | } |
| 852 | |
Igor Murashkin | af1e299 | 2016-10-12 17:44:50 -0700 | [diff] [blame] | 853 | JNI_TEST(CompileAndRunIntObjectObjectMethod) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 854 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 855 | int gJava_MyClassNatives_fooSII_calls[kJniKindCount] = {}; |
| 856 | jint Java_MyClassNatives_fooSII(JNIEnv* env ATTRIBUTE_UNUSED, |
| 857 | jclass klass ATTRIBUTE_UNUSED, |
| 858 | jint x, |
| 859 | jint y) { |
| 860 | gJava_MyClassNatives_fooSII_calls[gCurrentJni]++; |
Shih-wei Liao | 82da44b | 2011-09-01 00:38:04 -0700 | [diff] [blame] | 861 | return x + y; |
| 862 | } |
| 863 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 864 | void JniCompilerTest::CompileAndRunStaticIntIntMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 865 | SetUpForTest(true, "fooSII", "(II)I", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 866 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooSII)); |
Shih-wei Liao | 82da44b | 2011-09-01 00:38:04 -0700 | [diff] [blame] | 867 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 868 | EXPECT_EQ(0, gJava_MyClassNatives_fooSII_calls[gCurrentJni]); |
Shih-wei Liao | 82da44b | 2011-09-01 00:38:04 -0700 | [diff] [blame] | 869 | jint result = env_->CallStaticIntMethod(jklass_, jmethod_, 20, 30); |
| 870 | EXPECT_EQ(50, result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 871 | EXPECT_EQ(1, gJava_MyClassNatives_fooSII_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 872 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 873 | gJava_MyClassNatives_fooSII_calls[gCurrentJni] = 0; |
Shih-wei Liao | 82da44b | 2011-09-01 00:38:04 -0700 | [diff] [blame] | 874 | } |
| 875 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 876 | JNI_TEST_CRITICAL(CompileAndRunStaticIntIntMethod) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 877 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 878 | int gJava_MyClassNatives_fooSDD_calls[kJniKindCount] = {}; |
| 879 | jdouble Java_MyClassNatives_fooSDD(JNIEnv* env ATTRIBUTE_UNUSED, |
| 880 | jclass klass ATTRIBUTE_UNUSED, |
| 881 | jdouble x, |
| 882 | jdouble y) { |
| 883 | gJava_MyClassNatives_fooSDD_calls[gCurrentJni]++; |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 884 | return x - y; // non-commutative operator |
| 885 | } |
| 886 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 887 | void JniCompilerTest::CompileAndRunStaticDoubleDoubleMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 888 | SetUpForTest(true, "fooSDD", "(DD)D", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 889 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooSDD)); |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 890 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 891 | EXPECT_EQ(0, gJava_MyClassNatives_fooSDD_calls[gCurrentJni]); |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 892 | jdouble result = env_->CallStaticDoubleMethod(jklass_, jmethod_, 99.0, 10.0); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 893 | EXPECT_DOUBLE_EQ(99.0 - 10.0, result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 894 | EXPECT_EQ(1, gJava_MyClassNatives_fooSDD_calls[gCurrentJni]); |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 895 | jdouble a = 3.14159265358979323846; |
| 896 | jdouble b = 0.69314718055994530942; |
| 897 | result = env_->CallStaticDoubleMethod(jklass_, jmethod_, a, b); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 898 | EXPECT_DOUBLE_EQ(a - b, result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 899 | EXPECT_DOUBLE_EQ(2, gJava_MyClassNatives_fooSDD_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 900 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 901 | gJava_MyClassNatives_fooSDD_calls[gCurrentJni] = 0; |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 902 | } |
| 903 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 904 | JNI_TEST_CRITICAL(CompileAndRunStaticDoubleDoubleMethod) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 905 | |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 906 | // The x86 generic JNI code had a bug where it assumed a floating |
| 907 | // point return value would be in xmm0. We use log, to somehow ensure |
| 908 | // the compiler will use the floating point stack. |
| 909 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 910 | jdouble Java_MyClassNatives_logD(JNIEnv*, jclass, jdouble x) { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 911 | return log(x); |
| 912 | } |
| 913 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 914 | jdouble Java_MyClassNatives_logD_notNormal(JNIEnv*, jclass, jdouble x) { |
| 915 | EXPECT_DOUBLE_EQ(2.0, x); |
| 916 | return log(x); |
| 917 | } |
| 918 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 919 | void JniCompilerTest::RunStaticLogDoubleMethodImpl() { |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 920 | void* jni_handler; |
| 921 | if (IsCurrentJniNormal()) { |
| 922 | // This test seems a bit special, don't use a JNI wrapper here. |
| 923 | jni_handler = NORMAL_JNI_ONLY_NOWRAP(Java_MyClassNatives_logD); |
| 924 | } else { |
| 925 | jni_handler = CURRENT_JNI_WRAPPER(Java_MyClassNatives_logD_notNormal); |
| 926 | } |
| 927 | SetUpForTest(true, "logD", "(D)D", jni_handler); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 928 | |
| 929 | jdouble result = env_->CallStaticDoubleMethod(jklass_, jmethod_, 2.0); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 930 | EXPECT_DOUBLE_EQ(log(2.0), result); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 931 | } |
| 932 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 933 | JNI_TEST_CRITICAL(RunStaticLogDoubleMethod) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 934 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 935 | jfloat Java_MyClassNatives_logF(JNIEnv*, jclass, jfloat x) { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 936 | return logf(x); |
| 937 | } |
| 938 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 939 | void JniCompilerTest::RunStaticLogFloatMethodImpl() { |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 940 | void* jni_handler; |
| 941 | if (IsCurrentJniNormal()) { |
| 942 | // This test seems a bit special, don't use a JNI wrapper here. |
| 943 | jni_handler = NORMAL_JNI_ONLY_NOWRAP(Java_MyClassNatives_logF); |
| 944 | } else { |
| 945 | jni_handler = CURRENT_JNI_WRAPPER(Java_MyClassNatives_logF); |
| 946 | } |
| 947 | |
| 948 | SetUpForTest(true, "logF", "(F)F", jni_handler); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 949 | |
| 950 | jfloat result = env_->CallStaticFloatMethod(jklass_, jmethod_, 2.0); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 951 | EXPECT_FLOAT_EQ(logf(2.0), result); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 952 | } |
| 953 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 954 | JNI_TEST_CRITICAL(RunStaticLogFloatMethod) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 955 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 956 | jboolean Java_MyClassNatives_returnTrue(JNIEnv*, jclass) { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 957 | return JNI_TRUE; |
| 958 | } |
| 959 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 960 | jboolean Java_MyClassNatives_returnFalse(JNIEnv*, jclass) { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 961 | return JNI_FALSE; |
| 962 | } |
| 963 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 964 | jint Java_MyClassNatives_returnInt(JNIEnv*, jclass) { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 965 | return 42; |
| 966 | } |
| 967 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 968 | void JniCompilerTest::RunStaticReturnTrueImpl() { |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 969 | SetUpForTest(true, "returnTrue", "()Z", CURRENT_JNI_WRAPPER(Java_MyClassNatives_returnTrue)); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 970 | |
| 971 | jboolean result = env_->CallStaticBooleanMethod(jklass_, jmethod_); |
| 972 | EXPECT_TRUE(result); |
| 973 | } |
| 974 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 975 | JNI_TEST_CRITICAL(RunStaticReturnTrue) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 976 | |
| 977 | void JniCompilerTest::RunStaticReturnFalseImpl() { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 978 | SetUpForTest(true, "returnFalse", "()Z", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 979 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_returnFalse)); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 980 | |
| 981 | jboolean result = env_->CallStaticBooleanMethod(jklass_, jmethod_); |
| 982 | EXPECT_FALSE(result); |
| 983 | } |
| 984 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 985 | JNI_TEST_CRITICAL(RunStaticReturnFalse) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 986 | |
| 987 | void JniCompilerTest::RunGenericStaticReturnIntImpl() { |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 988 | SetUpForTest(true, "returnInt", "()I", CURRENT_JNI_WRAPPER(Java_MyClassNatives_returnInt)); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 989 | |
| 990 | jint result = env_->CallStaticIntMethod(jklass_, jmethod_); |
| 991 | EXPECT_EQ(42, result); |
| 992 | } |
| 993 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 994 | JNI_TEST_CRITICAL(RunGenericStaticReturnInt) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 995 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 996 | int gJava_MyClassNatives_returnDouble_calls[kJniKindCount] = {}; |
| 997 | jdouble Java_MyClassNatives_returnDouble(JNIEnv*, jclass) { |
| 998 | gJava_MyClassNatives_returnDouble_calls[gCurrentJni]++; |
| 999 | return 4.0; |
| 1000 | } |
| 1001 | |
| 1002 | void JniCompilerTest::RunGenericStaticReturnDoubleImpl() { |
| 1003 | SetUpForTest(true, "returnDouble", "()D", CURRENT_JNI_WRAPPER(Java_MyClassNatives_returnDouble)); |
| 1004 | |
| 1005 | jdouble result = env_->CallStaticDoubleMethod(jklass_, jmethod_); |
| 1006 | EXPECT_DOUBLE_EQ(4.0, result); |
| 1007 | EXPECT_EQ(1, gJava_MyClassNatives_returnDouble_calls[gCurrentJni]); |
| 1008 | |
| 1009 | gJava_MyClassNatives_returnDouble_calls[gCurrentJni] = 0; |
| 1010 | } |
| 1011 | |
| 1012 | JNI_TEST_CRITICAL(RunGenericStaticReturnDouble) |
| 1013 | |
| 1014 | jlong Java_MyClassNatives_returnLong(JNIEnv*, jclass) { |
| 1015 | return 0xFEEDDEADFEEDL; |
| 1016 | } |
| 1017 | |
| 1018 | void JniCompilerTest::RunGenericStaticReturnLongImpl() { |
| 1019 | SetUpForTest(true, "returnLong", "()J", CURRENT_JNI_WRAPPER(Java_MyClassNatives_returnLong)); |
| 1020 | |
| 1021 | jlong result = env_->CallStaticLongMethod(jklass_, jmethod_); |
| 1022 | EXPECT_EQ(0xFEEDDEADFEEDL, result); |
| 1023 | } |
| 1024 | |
| 1025 | JNI_TEST_CRITICAL(RunGenericStaticReturnLong) |
| 1026 | |
| 1027 | int gJava_MyClassNatives_fooSIOO_calls[kJniKindCount] = {}; |
| 1028 | jobject Java_MyClassNatives_fooSIOO(JNIEnv*, jclass klass, jint x, jobject y, jobject z) { |
| 1029 | gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]++; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1030 | switch (x) { |
| 1031 | case 1: |
| 1032 | return y; |
| 1033 | case 2: |
| 1034 | return z; |
| 1035 | default: |
| 1036 | return klass; |
| 1037 | } |
| 1038 | } |
| 1039 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1040 | void JniCompilerTest::CompileAndRunStaticIntObjectObjectMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1041 | SetUpForTest(true, "fooSIOO", |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1042 | "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1043 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooSIOO)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1044 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1045 | EXPECT_EQ(0, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1046 | jobject result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, nullptr, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1047 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1048 | EXPECT_EQ(1, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1049 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1050 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, nullptr, jobj_); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1051 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1052 | EXPECT_EQ(2, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1053 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, nullptr, jobj_); |
| 1054 | EXPECT_TRUE(env_->IsSameObject(nullptr, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1055 | EXPECT_EQ(3, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1056 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 2, nullptr, jobj_); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1057 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1058 | EXPECT_EQ(4, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1059 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1060 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, jobj_, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1061 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1062 | EXPECT_EQ(5, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1063 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, jobj_, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1064 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1065 | EXPECT_EQ(6, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1066 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 2, jobj_, nullptr); |
| 1067 | EXPECT_TRUE(env_->IsSameObject(nullptr, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1068 | EXPECT_EQ(7, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1069 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1070 | gJava_MyClassNatives_fooSIOO_calls[gCurrentJni] = 0; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1071 | } |
| 1072 | |
Igor Murashkin | af1e299 | 2016-10-12 17:44:50 -0700 | [diff] [blame] | 1073 | JNI_TEST(CompileAndRunStaticIntObjectObjectMethod) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1074 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1075 | int gJava_MyClassNatives_fooSSIOO_calls[kJniKindCount] = {}; |
| 1076 | jobject Java_MyClassNatives_fooSSIOO(JNIEnv*, jclass klass, jint x, jobject y, jobject z) { |
| 1077 | gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]++; |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 1078 | switch (x) { |
| 1079 | case 1: |
| 1080 | return y; |
| 1081 | case 2: |
| 1082 | return z; |
| 1083 | default: |
| 1084 | return klass; |
| 1085 | } |
| 1086 | } |
| 1087 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1088 | void JniCompilerTest::CompileAndRunStaticSynchronizedIntObjectObjectMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1089 | SetUpForTest(true, "fooSSIOO", |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1090 | "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1091 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooSSIOO)); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 1092 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1093 | EXPECT_EQ(0, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1094 | jobject result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, nullptr, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1095 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1096 | EXPECT_EQ(1, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1097 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1098 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, nullptr, jobj_); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1099 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1100 | EXPECT_EQ(2, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1101 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, nullptr, jobj_); |
| 1102 | EXPECT_TRUE(env_->IsSameObject(nullptr, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1103 | EXPECT_EQ(3, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1104 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 2, nullptr, jobj_); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1105 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1106 | EXPECT_EQ(4, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1107 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1108 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, jobj_, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1109 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1110 | EXPECT_EQ(5, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1111 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, jobj_, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1112 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1113 | EXPECT_EQ(6, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1114 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 2, jobj_, nullptr); |
| 1115 | EXPECT_TRUE(env_->IsSameObject(nullptr, result)); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1116 | EXPECT_EQ(7, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1117 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1118 | gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni] = 0; |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 1119 | } |
| 1120 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1121 | // TODO: Maybe. @FastNative support for returning Objects? |
| 1122 | JNI_TEST_NORMAL_ONLY(CompileAndRunStaticSynchronizedIntObjectObjectMethod) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1123 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1124 | void Java_MyClassNatives_throwException(JNIEnv* env, jobject) { |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 1125 | jclass c = env->FindClass("java/lang/RuntimeException"); |
| 1126 | env->ThrowNew(c, "hello"); |
| 1127 | } |
Ian Rogers | 45a76cb | 2011-07-21 22:00:15 -0700 | [diff] [blame] | 1128 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1129 | void JniCompilerTest::ExceptionHandlingImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1130 | { |
| 1131 | ASSERT_FALSE(runtime_->IsStarted()); |
| 1132 | ScopedObjectAccess soa(Thread::Current()); |
| 1133 | class_loader_ = LoadDex("MyClassNatives"); |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 1134 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1135 | // all compilation needs to happen before Runtime::Start |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1136 | CompileForTestWithCurrentJni(class_loader_, false, "foo", "()V"); |
| 1137 | CompileForTestWithCurrentJni(class_loader_, false, "throwException", "()V"); |
| 1138 | CompileForTestWithCurrentJni(class_loader_, false, "foo", "()V"); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1139 | } |
| 1140 | // Start runtime to avoid re-initialization in SetupForTest. |
| 1141 | Thread::Current()->TransitionFromSuspendedToRunnable(); |
Brian Carlstrom | bd86bcc | 2013-03-10 20:26:16 -0700 | [diff] [blame] | 1142 | bool started = runtime_->Start(); |
| 1143 | CHECK(started); |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 1144 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1145 | gJava_MyClassNatives_foo_calls[gCurrentJni] = 0; |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 1146 | |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1147 | // Check a single call of a JNI method is ok |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1148 | SetUpForTest(false, "foo", "()V", CURRENT_JNI_WRAPPER(Java_MyClassNatives_foo)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1149 | env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1150 | EXPECT_EQ(1, gJava_MyClassNatives_foo_calls[gCurrentJni]); |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1151 | EXPECT_FALSE(Thread::Current()->IsExceptionPending()); |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 1152 | |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1153 | // Get class for exception we expect to be thrown |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1154 | ScopedLocalRef<jclass> jlre(env_, env_->FindClass("java/lang/RuntimeException")); |
| 1155 | SetUpForTest(false, "throwException", "()V", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1156 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_throwException)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1157 | // Call Java_MyClassNatives_throwException (JNI method that throws exception) |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 1158 | env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1159 | EXPECT_EQ(1, gJava_MyClassNatives_foo_calls[gCurrentJni]); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1160 | EXPECT_TRUE(env_->ExceptionCheck() == JNI_TRUE); |
| 1161 | ScopedLocalRef<jthrowable> exception(env_, env_->ExceptionOccurred()); |
| 1162 | env_->ExceptionClear(); |
| 1163 | EXPECT_TRUE(env_->IsInstanceOf(exception.get(), jlre.get())); |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 1164 | |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1165 | // Check a single call of a JNI method is ok |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1166 | SetUpForTest(false, "foo", "()V", reinterpret_cast<void*>(&Java_MyClassNatives_foo)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 1167 | env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1168 | EXPECT_EQ(2, gJava_MyClassNatives_foo_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1169 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1170 | gJava_MyClassNatives_foo_calls[gCurrentJni] = 0; |
Ian Rogers | 45a76cb | 2011-07-21 22:00:15 -0700 | [diff] [blame] | 1171 | } |
| 1172 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1173 | JNI_TEST(ExceptionHandling) |
| 1174 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1175 | jint Java_MyClassNatives_nativeUpCall(JNIEnv* env, jobject thisObj, jint i) { |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 1176 | if (i <= 0) { |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1177 | // We want to check raw Object* / Array* below |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1178 | ScopedObjectAccess soa(env); |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 1179 | |
| 1180 | // Build stack trace |
Sebastien Hertz | ee1d79a | 2014-02-21 15:46:30 +0100 | [diff] [blame] | 1181 | jobject internal = Thread::Current()->CreateInternalStackTrace<false>(soa); |
Ian Rogers | 53b8b09 | 2014-03-13 23:45:53 -0700 | [diff] [blame] | 1182 | jobjectArray ste_array = Thread::InternalStackTraceToStackTraceElementArray(soa, internal); |
Mathieu Chartier | 0795f23 | 2016-09-27 18:43:30 -0700 | [diff] [blame] | 1183 | ObjPtr<mirror::ObjectArray<mirror::StackTraceElement>> trace_array = |
| 1184 | soa.Decode<mirror::ObjectArray<mirror::StackTraceElement>>(ste_array); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1185 | EXPECT_TRUE(trace_array != nullptr); |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 1186 | EXPECT_EQ(11, trace_array->GetLength()); |
| 1187 | |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 1188 | // Check stack trace entries have expected values |
Andreas Gampe | 277ccbd | 2014-11-03 21:36:10 -0800 | [diff] [blame] | 1189 | for (int32_t j = 0; j < trace_array->GetLength(); ++j) { |
| 1190 | EXPECT_EQ(-2, trace_array->Get(j)->GetLineNumber()); |
| 1191 | mirror::StackTraceElement* ste = trace_array->Get(j); |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 1192 | EXPECT_STREQ("MyClassNatives.java", ste->GetFileName()->ToModifiedUtf8().c_str()); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1193 | EXPECT_STREQ("MyClassNatives", ste->GetDeclaringClass()->ToModifiedUtf8().c_str()); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1194 | EXPECT_EQ(("fooI" + CurrentJniStringSuffix()), ste->GetMethodName()->ToModifiedUtf8()); |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 1195 | } |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 1196 | |
| 1197 | // end recursion |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 1198 | return 0; |
| 1199 | } else { |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1200 | jclass jklass = env->FindClass("MyClassNatives"); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1201 | EXPECT_TRUE(jklass != nullptr); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1202 | jmethodID jmethod = env->GetMethodID(jklass, |
| 1203 | ("fooI" + CurrentJniStringSuffix()).c_str(), |
| 1204 | "(I)I"); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1205 | EXPECT_TRUE(jmethod != nullptr); |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 1206 | |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 1207 | // Recurse with i - 1 |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 1208 | jint result = env->CallNonvirtualIntMethod(thisObj, jklass, jmethod, i - 1); |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 1209 | |
| 1210 | // Return sum of all depths |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 1211 | return i + result; |
| 1212 | } |
| 1213 | } |
| 1214 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1215 | void JniCompilerTest::NativeStackTraceElementImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1216 | SetUpForTest(false, "fooI", "(I)I", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1217 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_nativeUpCall)); |
| 1218 | |
| 1219 | // Usual # local references on stack check fails because nativeUpCall calls itself recursively, |
| 1220 | // each time the # of local references will therefore go up. |
| 1221 | ScopedDisableCheckNumStackReferences disable_num_stack_check; |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 1222 | jint result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 10); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1223 | |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 1224 | EXPECT_EQ(10+9+8+7+6+5+4+3+2+1, result); |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 1225 | } |
| 1226 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1227 | JNI_TEST(NativeStackTraceElement) |
| 1228 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1229 | jobject Java_MyClassNatives_fooO(JNIEnv* env, jobject, jobject x) { |
Shih-wei Liao | 558788e | 2011-09-01 02:39:11 -0700 | [diff] [blame] | 1230 | return env->NewGlobalRef(x); |
| 1231 | } |
| 1232 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1233 | void JniCompilerTest::ReturnGlobalRefImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1234 | SetUpForTest(false, "fooO", "(Ljava/lang/Object;)Ljava/lang/Object;", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1235 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooO)); |
Shih-wei Liao | 558788e | 2011-09-01 02:39:11 -0700 | [diff] [blame] | 1236 | jobject result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, jobj_); |
| 1237 | EXPECT_EQ(JNILocalRefType, env_->GetObjectRefType(result)); |
| 1238 | EXPECT_TRUE(env_->IsSameObject(result, jobj_)); |
| 1239 | } |
| 1240 | |
Igor Murashkin | af1e299 | 2016-10-12 17:44:50 -0700 | [diff] [blame] | 1241 | JNI_TEST(ReturnGlobalRef) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1242 | |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 1243 | jint local_ref_test(JNIEnv* env, jobject thisObj, jint x) { |
| 1244 | // Add 10 local references |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1245 | ScopedObjectAccess soa(env); |
Ian Rogers | 5a7a74a | 2011-09-26 16:32:29 -0700 | [diff] [blame] | 1246 | for (int i = 0; i < 10; i++) { |
Mathieu Chartier | 0795f23 | 2016-09-27 18:43:30 -0700 | [diff] [blame] | 1247 | soa.AddLocalReference<jobject>(soa.Decode<mirror::Object>(thisObj)); |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 1248 | } |
| 1249 | return x+1; |
| 1250 | } |
| 1251 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1252 | void JniCompilerTest::LocalReferenceTableClearingTestImpl() { |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1253 | SetUpForTest(false, "fooI", "(I)I", CURRENT_JNI_WRAPPER(local_ref_test)); |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 1254 | // 1000 invocations of a method that adds 10 local references |
Elliott Hughes | b25c3f6 | 2012-03-26 16:35:06 -0700 | [diff] [blame] | 1255 | for (int i = 0; i < 1000; i++) { |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 1256 | jint result = env_->CallIntMethod(jobj_, jmethod_, i); |
| 1257 | EXPECT_TRUE(result == i + 1); |
| 1258 | } |
| 1259 | } |
| 1260 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1261 | JNI_TEST(LocalReferenceTableClearingTest) |
| 1262 | |
Ian Rogers | b9231c8 | 2011-09-05 22:13:19 -0700 | [diff] [blame] | 1263 | void my_arraycopy(JNIEnv* env, jclass klass, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length) { |
| 1264 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jklass_, klass)); |
| 1265 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jklass_, dst)); |
Ian Rogers | 82f3e09 | 2011-09-05 22:54:45 -0700 | [diff] [blame] | 1266 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jobj_, src)); |
Ian Rogers | b9231c8 | 2011-09-05 22:13:19 -0700 | [diff] [blame] | 1267 | EXPECT_EQ(1234, src_pos); |
| 1268 | EXPECT_EQ(5678, dst_pos); |
| 1269 | EXPECT_EQ(9876, length); |
| 1270 | } |
| 1271 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1272 | void JniCompilerTest::JavaLangSystemArrayCopyImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1273 | SetUpForTest(true, "arraycopy", "(Ljava/lang/Object;ILjava/lang/Object;II)V", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1274 | CURRENT_JNI_WRAPPER(my_arraycopy)); |
Ian Rogers | 82f3e09 | 2011-09-05 22:54:45 -0700 | [diff] [blame] | 1275 | env_->CallStaticVoidMethod(jklass_, jmethod_, jobj_, 1234, jklass_, 5678, 9876); |
Ian Rogers | b9231c8 | 2011-09-05 22:13:19 -0700 | [diff] [blame] | 1276 | } |
| 1277 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1278 | JNI_TEST(JavaLangSystemArrayCopy) |
| 1279 | |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1280 | jboolean my_casi(JNIEnv* env, jobject unsafe, jobject obj, jlong offset, jint expected, jint newval) { |
| 1281 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jobj_, unsafe)); |
| 1282 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jobj_, obj)); |
Ian Rogers | 0f67847 | 2014-03-10 16:18:37 -0700 | [diff] [blame] | 1283 | EXPECT_EQ(INT64_C(0x12345678ABCDEF88), offset); |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1284 | EXPECT_EQ(static_cast<jint>(0xCAFEF00D), expected); |
| 1285 | EXPECT_EQ(static_cast<jint>(0xEBADF00D), newval); |
| 1286 | return JNI_TRUE; |
| 1287 | } |
| 1288 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1289 | void JniCompilerTest::CompareAndSwapIntImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1290 | SetUpForTest(false, "compareAndSwapInt", "(Ljava/lang/Object;JII)Z", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1291 | CURRENT_JNI_WRAPPER(my_casi)); |
Ian Rogers | 0f67847 | 2014-03-10 16:18:37 -0700 | [diff] [blame] | 1292 | jboolean result = env_->CallBooleanMethod(jobj_, jmethod_, jobj_, INT64_C(0x12345678ABCDEF88), |
| 1293 | 0xCAFEF00D, 0xEBADF00D); |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1294 | EXPECT_EQ(result, JNI_TRUE); |
| 1295 | } |
| 1296 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1297 | JNI_TEST(CompareAndSwapInt) |
| 1298 | |
Ian Rogers | c779284 | 2012-03-03 15:36:20 -0800 | [diff] [blame] | 1299 | jint my_gettext(JNIEnv* env, jclass klass, jlong val1, jobject obj1, jlong val2, jobject obj2) { |
| 1300 | EXPECT_TRUE(env->IsInstanceOf(JniCompilerTest::jobj_, klass)); |
| 1301 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jobj_, obj1)); |
| 1302 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jobj_, obj2)); |
| 1303 | EXPECT_EQ(0x12345678ABCDEF88ll, val1); |
| 1304 | EXPECT_EQ(0x7FEDCBA987654321ll, val2); |
| 1305 | return 42; |
| 1306 | } |
| 1307 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1308 | void JniCompilerTest::GetTextImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1309 | SetUpForTest(true, "getText", "(JLjava/lang/Object;JLjava/lang/Object;)I", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1310 | CURRENT_JNI_WRAPPER(my_gettext)); |
Ian Rogers | c779284 | 2012-03-03 15:36:20 -0800 | [diff] [blame] | 1311 | jint result = env_->CallStaticIntMethod(jklass_, jmethod_, 0x12345678ABCDEF88ll, jobj_, |
Ian Rogers | 0f67847 | 2014-03-10 16:18:37 -0700 | [diff] [blame] | 1312 | INT64_C(0x7FEDCBA987654321), jobj_); |
Ian Rogers | c779284 | 2012-03-03 15:36:20 -0800 | [diff] [blame] | 1313 | EXPECT_EQ(result, 42); |
| 1314 | } |
| 1315 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1316 | JNI_TEST(GetText) |
| 1317 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1318 | int gJava_MyClassNatives_GetSinkProperties_calls[kJniKindCount] = {}; |
| 1319 | jarray Java_MyClassNatives_GetSinkProperties(JNIEnv*, jobject thisObj, jstring s) { |
Vladimir Marko | 4e24b9d | 2014-07-24 17:01:58 +0100 | [diff] [blame] | 1320 | EXPECT_EQ(s, nullptr); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1321 | gJava_MyClassNatives_GetSinkProperties_calls[gCurrentJni]++; |
| 1322 | |
| 1323 | Thread* self = Thread::Current(); |
Vladimir Marko | 4e24b9d | 2014-07-24 17:01:58 +0100 | [diff] [blame] | 1324 | ScopedObjectAccess soa(self); |
Mathieu Chartier | 1cc62e4 | 2016-10-03 18:01:28 -0700 | [diff] [blame] | 1325 | EXPECT_TRUE(self->HoldsLock(soa.Decode<mirror::Object>(thisObj).Ptr())); |
Vladimir Marko | 4e24b9d | 2014-07-24 17:01:58 +0100 | [diff] [blame] | 1326 | return nullptr; |
| 1327 | } |
| 1328 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1329 | void JniCompilerTest::GetSinkPropertiesNativeImpl() { |
Vladimir Marko | 4e24b9d | 2014-07-24 17:01:58 +0100 | [diff] [blame] | 1330 | SetUpForTest(false, "getSinkPropertiesNative", "(Ljava/lang/String;)[Ljava/lang/Object;", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1331 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_GetSinkProperties)); |
Vladimir Marko | 4e24b9d | 2014-07-24 17:01:58 +0100 | [diff] [blame] | 1332 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1333 | EXPECT_EQ(0, gJava_MyClassNatives_GetSinkProperties_calls[gCurrentJni]); |
Vladimir Marko | 4e24b9d | 2014-07-24 17:01:58 +0100 | [diff] [blame] | 1334 | jarray result = down_cast<jarray>( |
| 1335 | env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, nullptr)); |
| 1336 | EXPECT_EQ(nullptr, result); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1337 | EXPECT_EQ(1, gJava_MyClassNatives_GetSinkProperties_calls[gCurrentJni]); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1338 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1339 | gJava_MyClassNatives_GetSinkProperties_calls[gCurrentJni] = 0; |
Brian Carlstrom | fc7120c | 2012-08-27 13:43:25 -0700 | [diff] [blame] | 1340 | } |
| 1341 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1342 | // @FastNative doesn't support 'synchronized' keyword and |
| 1343 | // never will -- locking functions aren't fast. |
| 1344 | JNI_TEST_NORMAL_ONLY(GetSinkPropertiesNative) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1345 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1346 | // This should return jclass, but we're imitating a bug pattern. |
| 1347 | jobject Java_MyClassNatives_instanceMethodThatShouldReturnClass(JNIEnv* env, jobject) { |
| 1348 | return env->NewStringUTF("not a class!"); |
| 1349 | } |
| 1350 | |
| 1351 | // This should return jclass, but we're imitating a bug pattern. |
| 1352 | jobject Java_MyClassNatives_staticMethodThatShouldReturnClass(JNIEnv* env, jclass) { |
| 1353 | return env->NewStringUTF("not a class!"); |
| 1354 | } |
| 1355 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1356 | void JniCompilerTest::UpcallReturnTypeChecking_InstanceImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1357 | SetUpForTest(false, "instanceMethodThatShouldReturnClass", "()Ljava/lang/Class;", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1358 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_instanceMethodThatShouldReturnClass)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1359 | |
| 1360 | CheckJniAbortCatcher check_jni_abort_catcher; |
Elliott Hughes | 3f6635a | 2012-06-19 13:37:49 -0700 | [diff] [blame] | 1361 | // This native method is bad, and tries to return a jstring as a jclass. |
| 1362 | env_->CallObjectMethod(jobj_, jmethod_); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1363 | check_jni_abort_catcher.Check(std::string() + "attempt to return an instance " + |
| 1364 | "of java.lang.String from java.lang.Class " + |
| 1365 | "MyClassNatives.instanceMethodThatShouldReturnClass" + |
| 1366 | CurrentJniStringSuffix() + "()"); |
Elliott Hughes | 3f6635a | 2012-06-19 13:37:49 -0700 | [diff] [blame] | 1367 | |
| 1368 | // Here, we just call the method incorrectly; we should catch that too. |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 1369 | env_->CallObjectMethod(jobj_, jmethod_); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1370 | check_jni_abort_catcher.Check(std::string() + "attempt to return an instance " + |
| 1371 | "of java.lang.String from java.lang.Class " + |
| 1372 | "MyClassNatives.instanceMethodThatShouldReturnClass" + |
| 1373 | CurrentJniStringSuffix() + "()"); |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 1374 | env_->CallStaticObjectMethod(jklass_, jmethod_); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1375 | check_jni_abort_catcher.Check(std::string() + "calling non-static method " + |
| 1376 | "java.lang.Class " + |
| 1377 | "MyClassNatives.instanceMethodThatShouldReturnClass" + |
| 1378 | CurrentJniStringSuffix() + "() with CallStaticObjectMethodV"); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1379 | } |
| 1380 | |
Igor Murashkin | af1e299 | 2016-10-12 17:44:50 -0700 | [diff] [blame] | 1381 | JNI_TEST(UpcallReturnTypeChecking_Instance) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1382 | |
| 1383 | void JniCompilerTest::UpcallReturnTypeChecking_StaticImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1384 | SetUpForTest(true, "staticMethodThatShouldReturnClass", "()Ljava/lang/Class;", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1385 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_staticMethodThatShouldReturnClass)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1386 | |
| 1387 | CheckJniAbortCatcher check_jni_abort_catcher; |
Elliott Hughes | 3f6635a | 2012-06-19 13:37:49 -0700 | [diff] [blame] | 1388 | // This native method is bad, and tries to return a jstring as a jclass. |
| 1389 | env_->CallStaticObjectMethod(jklass_, jmethod_); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1390 | check_jni_abort_catcher.Check(std::string() + "attempt to return an instance " + |
| 1391 | "of java.lang.String from java.lang.Class " + |
| 1392 | "MyClassNatives.staticMethodThatShouldReturnClass" + |
| 1393 | CurrentJniStringSuffix() + "()"); |
Elliott Hughes | 3f6635a | 2012-06-19 13:37:49 -0700 | [diff] [blame] | 1394 | |
| 1395 | // Here, we just call the method incorrectly; we should catch that too. |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 1396 | env_->CallStaticObjectMethod(jklass_, jmethod_); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1397 | check_jni_abort_catcher.Check(std::string() + "attempt to return an instance " + |
| 1398 | "of java.lang.String from java.lang.Class " + |
| 1399 | "MyClassNatives.staticMethodThatShouldReturnClass" + |
| 1400 | CurrentJniStringSuffix() + "()"); |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 1401 | env_->CallObjectMethod(jobj_, jmethod_); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1402 | check_jni_abort_catcher.Check(std::string() + "calling static method " + |
| 1403 | "java.lang.Class " + |
| 1404 | "MyClassNatives.staticMethodThatShouldReturnClass" + |
| 1405 | CurrentJniStringSuffix() + "() with CallObjectMethodV"); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1406 | } |
| 1407 | |
Igor Murashkin | af1e299 | 2016-10-12 17:44:50 -0700 | [diff] [blame] | 1408 | JNI_TEST(UpcallReturnTypeChecking_Static) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1409 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1410 | // This should take jclass, but we're imitating a bug pattern. |
| 1411 | void Java_MyClassNatives_instanceMethodThatShouldTakeClass(JNIEnv*, jobject, jclass) { |
| 1412 | } |
| 1413 | |
| 1414 | // This should take jclass, but we're imitating a bug pattern. |
| 1415 | void Java_MyClassNatives_staticMethodThatShouldTakeClass(JNIEnv*, jclass, jclass) { |
| 1416 | } |
| 1417 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1418 | void JniCompilerTest::UpcallArgumentTypeChecking_InstanceImpl() { |
Andreas Gampe | 369810a | 2015-01-14 19:53:31 -0800 | [diff] [blame] | 1419 | // This will lead to error messages in the log. |
| 1420 | ScopedLogSeverity sls(LogSeverity::FATAL); |
| 1421 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1422 | SetUpForTest(false, "instanceMethodThatShouldTakeClass", "(ILjava/lang/Class;)V", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1423 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_instanceMethodThatShouldTakeClass)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1424 | |
| 1425 | CheckJniAbortCatcher check_jni_abort_catcher; |
| 1426 | // We deliberately pass a bad second argument here. |
| 1427 | env_->CallVoidMethod(jobj_, jmethod_, 123, env_->NewStringUTF("not a class!")); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1428 | check_jni_abort_catcher.Check(std::string() + "bad arguments passed to void " + |
| 1429 | "MyClassNatives.instanceMethodThatShouldTakeClass" + |
| 1430 | CurrentJniStringSuffix() + "(int, java.lang.Class)"); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1431 | } |
| 1432 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1433 | JNI_TEST(UpcallArgumentTypeChecking_Instance) |
| 1434 | |
| 1435 | void JniCompilerTest::UpcallArgumentTypeChecking_StaticImpl() { |
Andreas Gampe | 369810a | 2015-01-14 19:53:31 -0800 | [diff] [blame] | 1436 | // This will lead to error messages in the log. |
| 1437 | ScopedLogSeverity sls(LogSeverity::FATAL); |
| 1438 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 1439 | SetUpForTest(true, "staticMethodThatShouldTakeClass", "(ILjava/lang/Class;)V", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1440 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_staticMethodThatShouldTakeClass)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1441 | |
| 1442 | CheckJniAbortCatcher check_jni_abort_catcher; |
| 1443 | // We deliberately pass a bad second argument here. |
| 1444 | env_->CallStaticVoidMethod(jklass_, jmethod_, 123, env_->NewStringUTF("not a class!")); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1445 | check_jni_abort_catcher.Check(std::string() + "bad arguments passed to void " + |
| 1446 | "MyClassNatives.staticMethodThatShouldTakeClass" + |
| 1447 | CurrentJniStringSuffix() + "(int, java.lang.Class)"); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1448 | } |
| 1449 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1450 | JNI_TEST(UpcallArgumentTypeChecking_Static) |
| 1451 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1452 | jfloat Java_MyClassNatives_checkFloats(JNIEnv*, jobject, jfloat f1, jfloat f2) { |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1453 | return f1 - f2; // non-commutative operator |
| 1454 | } |
| 1455 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1456 | void JniCompilerTest::CompileAndRunFloatFloatMethodImpl() { |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1457 | SetUpForTest(false, "checkFloats", "(FF)F", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1458 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_checkFloats)); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1459 | |
| 1460 | jfloat result = env_->CallNonvirtualFloatMethod(jobj_, jklass_, jmethod_, |
| 1461 | 99.0F, 10.0F); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 1462 | EXPECT_FLOAT_EQ(99.0F - 10.0F, result); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1463 | jfloat a = 3.14159F; |
| 1464 | jfloat b = 0.69314F; |
| 1465 | result = env_->CallNonvirtualFloatMethod(jobj_, jklass_, jmethod_, a, b); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 1466 | EXPECT_FLOAT_EQ(a - b, result); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1467 | } |
| 1468 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1469 | JNI_TEST(CompileAndRunFloatFloatMethod) |
| 1470 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 1471 | void Java_MyClassNatives_checkParameterAlign(JNIEnv* env ATTRIBUTE_UNUSED, |
| 1472 | jobject thisObj ATTRIBUTE_UNUSED, |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1473 | jint i1, |
| 1474 | jlong l1) { |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1475 | EXPECT_EQ(i1, 1234); |
Ian Rogers | 0f67847 | 2014-03-10 16:18:37 -0700 | [diff] [blame] | 1476 | EXPECT_EQ(l1, INT64_C(0x12345678ABCDEF0)); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1477 | } |
| 1478 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1479 | void JniCompilerTest::CheckParameterAlignImpl() { |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1480 | SetUpForTest(false, "checkParameterAlign", "(IJ)V", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1481 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_checkParameterAlign)); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1482 | |
Ian Rogers | 0f67847 | 2014-03-10 16:18:37 -0700 | [diff] [blame] | 1483 | env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_, 1234, INT64_C(0x12345678ABCDEF0)); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1484 | } |
| 1485 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1486 | JNI_TEST(CheckParameterAlign) |
| 1487 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1488 | void Java_MyClassNatives_maxParamNumber(JNIEnv* env, jobject, |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1489 | jobject o0, jobject o1, jobject o2, jobject o3, jobject o4, jobject o5, jobject o6, jobject o7, |
| 1490 | jobject o8, jobject o9, jobject o10, jobject o11, jobject o12, jobject o13, jobject o14, jobject o15, |
| 1491 | jobject o16, jobject o17, jobject o18, jobject o19, jobject o20, jobject o21, jobject o22, jobject o23, |
| 1492 | jobject o24, jobject o25, jobject o26, jobject o27, jobject o28, jobject o29, jobject o30, jobject o31, |
| 1493 | jobject o32, jobject o33, jobject o34, jobject o35, jobject o36, jobject o37, jobject o38, jobject o39, |
| 1494 | jobject o40, jobject o41, jobject o42, jobject o43, jobject o44, jobject o45, jobject o46, jobject o47, |
| 1495 | jobject o48, jobject o49, jobject o50, jobject o51, jobject o52, jobject o53, jobject o54, jobject o55, |
| 1496 | jobject o56, jobject o57, jobject o58, jobject o59, jobject o60, jobject o61, jobject o62, jobject o63, |
| 1497 | jobject o64, jobject o65, jobject o66, jobject o67, jobject o68, jobject o69, jobject o70, jobject o71, |
| 1498 | jobject o72, jobject o73, jobject o74, jobject o75, jobject o76, jobject o77, jobject o78, jobject o79, |
| 1499 | jobject o80, jobject o81, jobject o82, jobject o83, jobject o84, jobject o85, jobject o86, jobject o87, |
| 1500 | jobject o88, jobject o89, jobject o90, jobject o91, jobject o92, jobject o93, jobject o94, jobject o95, |
| 1501 | jobject o96, jobject o97, jobject o98, jobject o99, jobject o100, jobject o101, jobject o102, jobject o103, |
| 1502 | jobject o104, jobject o105, jobject o106, jobject o107, jobject o108, jobject o109, jobject o110, jobject o111, |
| 1503 | jobject o112, jobject o113, jobject o114, jobject o115, jobject o116, jobject o117, jobject o118, jobject o119, |
| 1504 | jobject o120, jobject o121, jobject o122, jobject o123, jobject o124, jobject o125, jobject o126, jobject o127, |
| 1505 | jobject o128, jobject o129, jobject o130, jobject o131, jobject o132, jobject o133, jobject o134, jobject o135, |
| 1506 | jobject o136, jobject o137, jobject o138, jobject o139, jobject o140, jobject o141, jobject o142, jobject o143, |
| 1507 | jobject o144, jobject o145, jobject o146, jobject o147, jobject o148, jobject o149, jobject o150, jobject o151, |
| 1508 | jobject o152, jobject o153, jobject o154, jobject o155, jobject o156, jobject o157, jobject o158, jobject o159, |
| 1509 | jobject o160, jobject o161, jobject o162, jobject o163, jobject o164, jobject o165, jobject o166, jobject o167, |
| 1510 | jobject o168, jobject o169, jobject o170, jobject o171, jobject o172, jobject o173, jobject o174, jobject o175, |
| 1511 | jobject o176, jobject o177, jobject o178, jobject o179, jobject o180, jobject o181, jobject o182, jobject o183, |
| 1512 | jobject o184, jobject o185, jobject o186, jobject o187, jobject o188, jobject o189, jobject o190, jobject o191, |
| 1513 | jobject o192, jobject o193, jobject o194, jobject o195, jobject o196, jobject o197, jobject o198, jobject o199, |
| 1514 | jobject o200, jobject o201, jobject o202, jobject o203, jobject o204, jobject o205, jobject o206, jobject o207, |
| 1515 | jobject o208, jobject o209, jobject o210, jobject o211, jobject o212, jobject o213, jobject o214, jobject o215, |
| 1516 | jobject o216, jobject o217, jobject o218, jobject o219, jobject o220, jobject o221, jobject o222, jobject o223, |
| 1517 | jobject o224, jobject o225, jobject o226, jobject o227, jobject o228, jobject o229, jobject o230, jobject o231, |
| 1518 | jobject o232, jobject o233, jobject o234, jobject o235, jobject o236, jobject o237, jobject o238, jobject o239, |
| 1519 | jobject o240, jobject o241, jobject o242, jobject o243, jobject o244, jobject o245, jobject o246, jobject o247, |
| 1520 | jobject o248, jobject o249, jobject o250, jobject o251, jobject o252, jobject o253) { |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1521 | // two tests possible |
| 1522 | if (o0 == nullptr) { |
| 1523 | // 1) everything is null |
| 1524 | EXPECT_TRUE(o0 == nullptr && o1 == nullptr && o2 == nullptr && o3 == nullptr && o4 == nullptr |
| 1525 | && o5 == nullptr && o6 == nullptr && o7 == nullptr && o8 == nullptr && o9 == nullptr |
| 1526 | && o10 == nullptr && o11 == nullptr && o12 == nullptr && o13 == nullptr && o14 == nullptr |
| 1527 | && o15 == nullptr && o16 == nullptr && o17 == nullptr && o18 == nullptr && o19 == nullptr |
| 1528 | && o20 == nullptr && o21 == nullptr && o22 == nullptr && o23 == nullptr && o24 == nullptr |
| 1529 | && o25 == nullptr && o26 == nullptr && o27 == nullptr && o28 == nullptr && o29 == nullptr |
| 1530 | && o30 == nullptr && o31 == nullptr && o32 == nullptr && o33 == nullptr && o34 == nullptr |
| 1531 | && o35 == nullptr && o36 == nullptr && o37 == nullptr && o38 == nullptr && o39 == nullptr |
| 1532 | && o40 == nullptr && o41 == nullptr && o42 == nullptr && o43 == nullptr && o44 == nullptr |
| 1533 | && o45 == nullptr && o46 == nullptr && o47 == nullptr && o48 == nullptr && o49 == nullptr |
| 1534 | && o50 == nullptr && o51 == nullptr && o52 == nullptr && o53 == nullptr && o54 == nullptr |
| 1535 | && o55 == nullptr && o56 == nullptr && o57 == nullptr && o58 == nullptr && o59 == nullptr |
| 1536 | && o60 == nullptr && o61 == nullptr && o62 == nullptr && o63 == nullptr && o64 == nullptr |
| 1537 | && o65 == nullptr && o66 == nullptr && o67 == nullptr && o68 == nullptr && o69 == nullptr |
| 1538 | && o70 == nullptr && o71 == nullptr && o72 == nullptr && o73 == nullptr && o74 == nullptr |
| 1539 | && o75 == nullptr && o76 == nullptr && o77 == nullptr && o78 == nullptr && o79 == nullptr |
| 1540 | && o80 == nullptr && o81 == nullptr && o82 == nullptr && o83 == nullptr && o84 == nullptr |
| 1541 | && o85 == nullptr && o86 == nullptr && o87 == nullptr && o88 == nullptr && o89 == nullptr |
| 1542 | && o90 == nullptr && o91 == nullptr && o92 == nullptr && o93 == nullptr && o94 == nullptr |
| 1543 | && o95 == nullptr && o96 == nullptr && o97 == nullptr && o98 == nullptr && o99 == nullptr |
| 1544 | && o100 == nullptr && o101 == nullptr && o102 == nullptr && o103 == nullptr && o104 == nullptr |
| 1545 | && o105 == nullptr && o106 == nullptr && o107 == nullptr && o108 == nullptr && o109 == nullptr |
| 1546 | && o110 == nullptr && o111 == nullptr && o112 == nullptr && o113 == nullptr && o114 == nullptr |
| 1547 | && o115 == nullptr && o116 == nullptr && o117 == nullptr && o118 == nullptr && o119 == nullptr |
| 1548 | && o120 == nullptr && o121 == nullptr && o122 == nullptr && o123 == nullptr && o124 == nullptr |
| 1549 | && o125 == nullptr && o126 == nullptr && o127 == nullptr && o128 == nullptr && o129 == nullptr |
| 1550 | && o130 == nullptr && o131 == nullptr && o132 == nullptr && o133 == nullptr && o134 == nullptr |
| 1551 | && o135 == nullptr && o136 == nullptr && o137 == nullptr && o138 == nullptr && o139 == nullptr |
| 1552 | && o140 == nullptr && o141 == nullptr && o142 == nullptr && o143 == nullptr && o144 == nullptr |
| 1553 | && o145 == nullptr && o146 == nullptr && o147 == nullptr && o148 == nullptr && o149 == nullptr |
| 1554 | && o150 == nullptr && o151 == nullptr && o152 == nullptr && o153 == nullptr && o154 == nullptr |
| 1555 | && o155 == nullptr && o156 == nullptr && o157 == nullptr && o158 == nullptr && o159 == nullptr |
| 1556 | && o160 == nullptr && o161 == nullptr && o162 == nullptr && o163 == nullptr && o164 == nullptr |
| 1557 | && o165 == nullptr && o166 == nullptr && o167 == nullptr && o168 == nullptr && o169 == nullptr |
| 1558 | && o170 == nullptr && o171 == nullptr && o172 == nullptr && o173 == nullptr && o174 == nullptr |
| 1559 | && o175 == nullptr && o176 == nullptr && o177 == nullptr && o178 == nullptr && o179 == nullptr |
| 1560 | && o180 == nullptr && o181 == nullptr && o182 == nullptr && o183 == nullptr && o184 == nullptr |
| 1561 | && o185 == nullptr && o186 == nullptr && o187 == nullptr && o188 == nullptr && o189 == nullptr |
| 1562 | && o190 == nullptr && o191 == nullptr && o192 == nullptr && o193 == nullptr && o194 == nullptr |
| 1563 | && o195 == nullptr && o196 == nullptr && o197 == nullptr && o198 == nullptr && o199 == nullptr |
| 1564 | && o200 == nullptr && o201 == nullptr && o202 == nullptr && o203 == nullptr && o204 == nullptr |
| 1565 | && o205 == nullptr && o206 == nullptr && o207 == nullptr && o208 == nullptr && o209 == nullptr |
| 1566 | && o210 == nullptr && o211 == nullptr && o212 == nullptr && o213 == nullptr && o214 == nullptr |
| 1567 | && o215 == nullptr && o216 == nullptr && o217 == nullptr && o218 == nullptr && o219 == nullptr |
| 1568 | && o220 == nullptr && o221 == nullptr && o222 == nullptr && o223 == nullptr && o224 == nullptr |
| 1569 | && o225 == nullptr && o226 == nullptr && o227 == nullptr && o228 == nullptr && o229 == nullptr |
| 1570 | && o230 == nullptr && o231 == nullptr && o232 == nullptr && o233 == nullptr && o234 == nullptr |
| 1571 | && o235 == nullptr && o236 == nullptr && o237 == nullptr && o238 == nullptr && o239 == nullptr |
| 1572 | && o240 == nullptr && o241 == nullptr && o242 == nullptr && o243 == nullptr && o244 == nullptr |
| 1573 | && o245 == nullptr && o246 == nullptr && o247 == nullptr && o248 == nullptr && o249 == nullptr |
| 1574 | && o250 == nullptr && o251 == nullptr && o252 == nullptr && o253 == nullptr); |
| 1575 | } else { |
| 1576 | EXPECT_EQ(0, env->GetArrayLength(reinterpret_cast<jarray>(o0))); |
| 1577 | EXPECT_EQ(1, env->GetArrayLength(reinterpret_cast<jarray>(o1))); |
| 1578 | EXPECT_EQ(2, env->GetArrayLength(reinterpret_cast<jarray>(o2))); |
| 1579 | EXPECT_EQ(3, env->GetArrayLength(reinterpret_cast<jarray>(o3))); |
| 1580 | EXPECT_EQ(4, env->GetArrayLength(reinterpret_cast<jarray>(o4))); |
| 1581 | EXPECT_EQ(5, env->GetArrayLength(reinterpret_cast<jarray>(o5))); |
| 1582 | EXPECT_EQ(6, env->GetArrayLength(reinterpret_cast<jarray>(o6))); |
| 1583 | EXPECT_EQ(7, env->GetArrayLength(reinterpret_cast<jarray>(o7))); |
| 1584 | EXPECT_EQ(8, env->GetArrayLength(reinterpret_cast<jarray>(o8))); |
| 1585 | EXPECT_EQ(9, env->GetArrayLength(reinterpret_cast<jarray>(o9))); |
| 1586 | EXPECT_EQ(10, env->GetArrayLength(reinterpret_cast<jarray>(o10))); |
| 1587 | EXPECT_EQ(11, env->GetArrayLength(reinterpret_cast<jarray>(o11))); |
| 1588 | EXPECT_EQ(12, env->GetArrayLength(reinterpret_cast<jarray>(o12))); |
| 1589 | EXPECT_EQ(13, env->GetArrayLength(reinterpret_cast<jarray>(o13))); |
| 1590 | EXPECT_EQ(14, env->GetArrayLength(reinterpret_cast<jarray>(o14))); |
| 1591 | EXPECT_EQ(15, env->GetArrayLength(reinterpret_cast<jarray>(o15))); |
| 1592 | EXPECT_EQ(16, env->GetArrayLength(reinterpret_cast<jarray>(o16))); |
| 1593 | EXPECT_EQ(17, env->GetArrayLength(reinterpret_cast<jarray>(o17))); |
| 1594 | EXPECT_EQ(18, env->GetArrayLength(reinterpret_cast<jarray>(o18))); |
| 1595 | EXPECT_EQ(19, env->GetArrayLength(reinterpret_cast<jarray>(o19))); |
| 1596 | EXPECT_EQ(20, env->GetArrayLength(reinterpret_cast<jarray>(o20))); |
| 1597 | EXPECT_EQ(21, env->GetArrayLength(reinterpret_cast<jarray>(o21))); |
| 1598 | EXPECT_EQ(22, env->GetArrayLength(reinterpret_cast<jarray>(o22))); |
| 1599 | EXPECT_EQ(23, env->GetArrayLength(reinterpret_cast<jarray>(o23))); |
| 1600 | EXPECT_EQ(24, env->GetArrayLength(reinterpret_cast<jarray>(o24))); |
| 1601 | EXPECT_EQ(25, env->GetArrayLength(reinterpret_cast<jarray>(o25))); |
| 1602 | EXPECT_EQ(26, env->GetArrayLength(reinterpret_cast<jarray>(o26))); |
| 1603 | EXPECT_EQ(27, env->GetArrayLength(reinterpret_cast<jarray>(o27))); |
| 1604 | EXPECT_EQ(28, env->GetArrayLength(reinterpret_cast<jarray>(o28))); |
| 1605 | EXPECT_EQ(29, env->GetArrayLength(reinterpret_cast<jarray>(o29))); |
| 1606 | EXPECT_EQ(30, env->GetArrayLength(reinterpret_cast<jarray>(o30))); |
| 1607 | EXPECT_EQ(31, env->GetArrayLength(reinterpret_cast<jarray>(o31))); |
| 1608 | EXPECT_EQ(32, env->GetArrayLength(reinterpret_cast<jarray>(o32))); |
| 1609 | EXPECT_EQ(33, env->GetArrayLength(reinterpret_cast<jarray>(o33))); |
| 1610 | EXPECT_EQ(34, env->GetArrayLength(reinterpret_cast<jarray>(o34))); |
| 1611 | EXPECT_EQ(35, env->GetArrayLength(reinterpret_cast<jarray>(o35))); |
| 1612 | EXPECT_EQ(36, env->GetArrayLength(reinterpret_cast<jarray>(o36))); |
| 1613 | EXPECT_EQ(37, env->GetArrayLength(reinterpret_cast<jarray>(o37))); |
| 1614 | EXPECT_EQ(38, env->GetArrayLength(reinterpret_cast<jarray>(o38))); |
| 1615 | EXPECT_EQ(39, env->GetArrayLength(reinterpret_cast<jarray>(o39))); |
| 1616 | EXPECT_EQ(40, env->GetArrayLength(reinterpret_cast<jarray>(o40))); |
| 1617 | EXPECT_EQ(41, env->GetArrayLength(reinterpret_cast<jarray>(o41))); |
| 1618 | EXPECT_EQ(42, env->GetArrayLength(reinterpret_cast<jarray>(o42))); |
| 1619 | EXPECT_EQ(43, env->GetArrayLength(reinterpret_cast<jarray>(o43))); |
| 1620 | EXPECT_EQ(44, env->GetArrayLength(reinterpret_cast<jarray>(o44))); |
| 1621 | EXPECT_EQ(45, env->GetArrayLength(reinterpret_cast<jarray>(o45))); |
| 1622 | EXPECT_EQ(46, env->GetArrayLength(reinterpret_cast<jarray>(o46))); |
| 1623 | EXPECT_EQ(47, env->GetArrayLength(reinterpret_cast<jarray>(o47))); |
| 1624 | EXPECT_EQ(48, env->GetArrayLength(reinterpret_cast<jarray>(o48))); |
| 1625 | EXPECT_EQ(49, env->GetArrayLength(reinterpret_cast<jarray>(o49))); |
| 1626 | EXPECT_EQ(50, env->GetArrayLength(reinterpret_cast<jarray>(o50))); |
| 1627 | EXPECT_EQ(51, env->GetArrayLength(reinterpret_cast<jarray>(o51))); |
| 1628 | EXPECT_EQ(52, env->GetArrayLength(reinterpret_cast<jarray>(o52))); |
| 1629 | EXPECT_EQ(53, env->GetArrayLength(reinterpret_cast<jarray>(o53))); |
| 1630 | EXPECT_EQ(54, env->GetArrayLength(reinterpret_cast<jarray>(o54))); |
| 1631 | EXPECT_EQ(55, env->GetArrayLength(reinterpret_cast<jarray>(o55))); |
| 1632 | EXPECT_EQ(56, env->GetArrayLength(reinterpret_cast<jarray>(o56))); |
| 1633 | EXPECT_EQ(57, env->GetArrayLength(reinterpret_cast<jarray>(o57))); |
| 1634 | EXPECT_EQ(58, env->GetArrayLength(reinterpret_cast<jarray>(o58))); |
| 1635 | EXPECT_EQ(59, env->GetArrayLength(reinterpret_cast<jarray>(o59))); |
| 1636 | EXPECT_EQ(60, env->GetArrayLength(reinterpret_cast<jarray>(o60))); |
| 1637 | EXPECT_EQ(61, env->GetArrayLength(reinterpret_cast<jarray>(o61))); |
| 1638 | EXPECT_EQ(62, env->GetArrayLength(reinterpret_cast<jarray>(o62))); |
| 1639 | EXPECT_EQ(63, env->GetArrayLength(reinterpret_cast<jarray>(o63))); |
| 1640 | EXPECT_EQ(64, env->GetArrayLength(reinterpret_cast<jarray>(o64))); |
| 1641 | EXPECT_EQ(65, env->GetArrayLength(reinterpret_cast<jarray>(o65))); |
| 1642 | EXPECT_EQ(66, env->GetArrayLength(reinterpret_cast<jarray>(o66))); |
| 1643 | EXPECT_EQ(67, env->GetArrayLength(reinterpret_cast<jarray>(o67))); |
| 1644 | EXPECT_EQ(68, env->GetArrayLength(reinterpret_cast<jarray>(o68))); |
| 1645 | EXPECT_EQ(69, env->GetArrayLength(reinterpret_cast<jarray>(o69))); |
| 1646 | EXPECT_EQ(70, env->GetArrayLength(reinterpret_cast<jarray>(o70))); |
| 1647 | EXPECT_EQ(71, env->GetArrayLength(reinterpret_cast<jarray>(o71))); |
| 1648 | EXPECT_EQ(72, env->GetArrayLength(reinterpret_cast<jarray>(o72))); |
| 1649 | EXPECT_EQ(73, env->GetArrayLength(reinterpret_cast<jarray>(o73))); |
| 1650 | EXPECT_EQ(74, env->GetArrayLength(reinterpret_cast<jarray>(o74))); |
| 1651 | EXPECT_EQ(75, env->GetArrayLength(reinterpret_cast<jarray>(o75))); |
| 1652 | EXPECT_EQ(76, env->GetArrayLength(reinterpret_cast<jarray>(o76))); |
| 1653 | EXPECT_EQ(77, env->GetArrayLength(reinterpret_cast<jarray>(o77))); |
| 1654 | EXPECT_EQ(78, env->GetArrayLength(reinterpret_cast<jarray>(o78))); |
| 1655 | EXPECT_EQ(79, env->GetArrayLength(reinterpret_cast<jarray>(o79))); |
| 1656 | EXPECT_EQ(80, env->GetArrayLength(reinterpret_cast<jarray>(o80))); |
| 1657 | EXPECT_EQ(81, env->GetArrayLength(reinterpret_cast<jarray>(o81))); |
| 1658 | EXPECT_EQ(82, env->GetArrayLength(reinterpret_cast<jarray>(o82))); |
| 1659 | EXPECT_EQ(83, env->GetArrayLength(reinterpret_cast<jarray>(o83))); |
| 1660 | EXPECT_EQ(84, env->GetArrayLength(reinterpret_cast<jarray>(o84))); |
| 1661 | EXPECT_EQ(85, env->GetArrayLength(reinterpret_cast<jarray>(o85))); |
| 1662 | EXPECT_EQ(86, env->GetArrayLength(reinterpret_cast<jarray>(o86))); |
| 1663 | EXPECT_EQ(87, env->GetArrayLength(reinterpret_cast<jarray>(o87))); |
| 1664 | EXPECT_EQ(88, env->GetArrayLength(reinterpret_cast<jarray>(o88))); |
| 1665 | EXPECT_EQ(89, env->GetArrayLength(reinterpret_cast<jarray>(o89))); |
| 1666 | EXPECT_EQ(90, env->GetArrayLength(reinterpret_cast<jarray>(o90))); |
| 1667 | EXPECT_EQ(91, env->GetArrayLength(reinterpret_cast<jarray>(o91))); |
| 1668 | EXPECT_EQ(92, env->GetArrayLength(reinterpret_cast<jarray>(o92))); |
| 1669 | EXPECT_EQ(93, env->GetArrayLength(reinterpret_cast<jarray>(o93))); |
| 1670 | EXPECT_EQ(94, env->GetArrayLength(reinterpret_cast<jarray>(o94))); |
| 1671 | EXPECT_EQ(95, env->GetArrayLength(reinterpret_cast<jarray>(o95))); |
| 1672 | EXPECT_EQ(96, env->GetArrayLength(reinterpret_cast<jarray>(o96))); |
| 1673 | EXPECT_EQ(97, env->GetArrayLength(reinterpret_cast<jarray>(o97))); |
| 1674 | EXPECT_EQ(98, env->GetArrayLength(reinterpret_cast<jarray>(o98))); |
| 1675 | EXPECT_EQ(99, env->GetArrayLength(reinterpret_cast<jarray>(o99))); |
| 1676 | EXPECT_EQ(100, env->GetArrayLength(reinterpret_cast<jarray>(o100))); |
| 1677 | EXPECT_EQ(101, env->GetArrayLength(reinterpret_cast<jarray>(o101))); |
| 1678 | EXPECT_EQ(102, env->GetArrayLength(reinterpret_cast<jarray>(o102))); |
| 1679 | EXPECT_EQ(103, env->GetArrayLength(reinterpret_cast<jarray>(o103))); |
| 1680 | EXPECT_EQ(104, env->GetArrayLength(reinterpret_cast<jarray>(o104))); |
| 1681 | EXPECT_EQ(105, env->GetArrayLength(reinterpret_cast<jarray>(o105))); |
| 1682 | EXPECT_EQ(106, env->GetArrayLength(reinterpret_cast<jarray>(o106))); |
| 1683 | EXPECT_EQ(107, env->GetArrayLength(reinterpret_cast<jarray>(o107))); |
| 1684 | EXPECT_EQ(108, env->GetArrayLength(reinterpret_cast<jarray>(o108))); |
| 1685 | EXPECT_EQ(109, env->GetArrayLength(reinterpret_cast<jarray>(o109))); |
| 1686 | EXPECT_EQ(110, env->GetArrayLength(reinterpret_cast<jarray>(o110))); |
| 1687 | EXPECT_EQ(111, env->GetArrayLength(reinterpret_cast<jarray>(o111))); |
| 1688 | EXPECT_EQ(112, env->GetArrayLength(reinterpret_cast<jarray>(o112))); |
| 1689 | EXPECT_EQ(113, env->GetArrayLength(reinterpret_cast<jarray>(o113))); |
| 1690 | EXPECT_EQ(114, env->GetArrayLength(reinterpret_cast<jarray>(o114))); |
| 1691 | EXPECT_EQ(115, env->GetArrayLength(reinterpret_cast<jarray>(o115))); |
| 1692 | EXPECT_EQ(116, env->GetArrayLength(reinterpret_cast<jarray>(o116))); |
| 1693 | EXPECT_EQ(117, env->GetArrayLength(reinterpret_cast<jarray>(o117))); |
| 1694 | EXPECT_EQ(118, env->GetArrayLength(reinterpret_cast<jarray>(o118))); |
| 1695 | EXPECT_EQ(119, env->GetArrayLength(reinterpret_cast<jarray>(o119))); |
| 1696 | EXPECT_EQ(120, env->GetArrayLength(reinterpret_cast<jarray>(o120))); |
| 1697 | EXPECT_EQ(121, env->GetArrayLength(reinterpret_cast<jarray>(o121))); |
| 1698 | EXPECT_EQ(122, env->GetArrayLength(reinterpret_cast<jarray>(o122))); |
| 1699 | EXPECT_EQ(123, env->GetArrayLength(reinterpret_cast<jarray>(o123))); |
| 1700 | EXPECT_EQ(124, env->GetArrayLength(reinterpret_cast<jarray>(o124))); |
| 1701 | EXPECT_EQ(125, env->GetArrayLength(reinterpret_cast<jarray>(o125))); |
| 1702 | EXPECT_EQ(126, env->GetArrayLength(reinterpret_cast<jarray>(o126))); |
| 1703 | EXPECT_EQ(127, env->GetArrayLength(reinterpret_cast<jarray>(o127))); |
| 1704 | EXPECT_EQ(128, env->GetArrayLength(reinterpret_cast<jarray>(o128))); |
| 1705 | EXPECT_EQ(129, env->GetArrayLength(reinterpret_cast<jarray>(o129))); |
| 1706 | EXPECT_EQ(130, env->GetArrayLength(reinterpret_cast<jarray>(o130))); |
| 1707 | EXPECT_EQ(131, env->GetArrayLength(reinterpret_cast<jarray>(o131))); |
| 1708 | EXPECT_EQ(132, env->GetArrayLength(reinterpret_cast<jarray>(o132))); |
| 1709 | EXPECT_EQ(133, env->GetArrayLength(reinterpret_cast<jarray>(o133))); |
| 1710 | EXPECT_EQ(134, env->GetArrayLength(reinterpret_cast<jarray>(o134))); |
| 1711 | EXPECT_EQ(135, env->GetArrayLength(reinterpret_cast<jarray>(o135))); |
| 1712 | EXPECT_EQ(136, env->GetArrayLength(reinterpret_cast<jarray>(o136))); |
| 1713 | EXPECT_EQ(137, env->GetArrayLength(reinterpret_cast<jarray>(o137))); |
| 1714 | EXPECT_EQ(138, env->GetArrayLength(reinterpret_cast<jarray>(o138))); |
| 1715 | EXPECT_EQ(139, env->GetArrayLength(reinterpret_cast<jarray>(o139))); |
| 1716 | EXPECT_EQ(140, env->GetArrayLength(reinterpret_cast<jarray>(o140))); |
| 1717 | EXPECT_EQ(141, env->GetArrayLength(reinterpret_cast<jarray>(o141))); |
| 1718 | EXPECT_EQ(142, env->GetArrayLength(reinterpret_cast<jarray>(o142))); |
| 1719 | EXPECT_EQ(143, env->GetArrayLength(reinterpret_cast<jarray>(o143))); |
| 1720 | EXPECT_EQ(144, env->GetArrayLength(reinterpret_cast<jarray>(o144))); |
| 1721 | EXPECT_EQ(145, env->GetArrayLength(reinterpret_cast<jarray>(o145))); |
| 1722 | EXPECT_EQ(146, env->GetArrayLength(reinterpret_cast<jarray>(o146))); |
| 1723 | EXPECT_EQ(147, env->GetArrayLength(reinterpret_cast<jarray>(o147))); |
| 1724 | EXPECT_EQ(148, env->GetArrayLength(reinterpret_cast<jarray>(o148))); |
| 1725 | EXPECT_EQ(149, env->GetArrayLength(reinterpret_cast<jarray>(o149))); |
| 1726 | EXPECT_EQ(150, env->GetArrayLength(reinterpret_cast<jarray>(o150))); |
| 1727 | EXPECT_EQ(151, env->GetArrayLength(reinterpret_cast<jarray>(o151))); |
| 1728 | EXPECT_EQ(152, env->GetArrayLength(reinterpret_cast<jarray>(o152))); |
| 1729 | EXPECT_EQ(153, env->GetArrayLength(reinterpret_cast<jarray>(o153))); |
| 1730 | EXPECT_EQ(154, env->GetArrayLength(reinterpret_cast<jarray>(o154))); |
| 1731 | EXPECT_EQ(155, env->GetArrayLength(reinterpret_cast<jarray>(o155))); |
| 1732 | EXPECT_EQ(156, env->GetArrayLength(reinterpret_cast<jarray>(o156))); |
| 1733 | EXPECT_EQ(157, env->GetArrayLength(reinterpret_cast<jarray>(o157))); |
| 1734 | EXPECT_EQ(158, env->GetArrayLength(reinterpret_cast<jarray>(o158))); |
| 1735 | EXPECT_EQ(159, env->GetArrayLength(reinterpret_cast<jarray>(o159))); |
| 1736 | EXPECT_EQ(160, env->GetArrayLength(reinterpret_cast<jarray>(o160))); |
| 1737 | EXPECT_EQ(161, env->GetArrayLength(reinterpret_cast<jarray>(o161))); |
| 1738 | EXPECT_EQ(162, env->GetArrayLength(reinterpret_cast<jarray>(o162))); |
| 1739 | EXPECT_EQ(163, env->GetArrayLength(reinterpret_cast<jarray>(o163))); |
| 1740 | EXPECT_EQ(164, env->GetArrayLength(reinterpret_cast<jarray>(o164))); |
| 1741 | EXPECT_EQ(165, env->GetArrayLength(reinterpret_cast<jarray>(o165))); |
| 1742 | EXPECT_EQ(166, env->GetArrayLength(reinterpret_cast<jarray>(o166))); |
| 1743 | EXPECT_EQ(167, env->GetArrayLength(reinterpret_cast<jarray>(o167))); |
| 1744 | EXPECT_EQ(168, env->GetArrayLength(reinterpret_cast<jarray>(o168))); |
| 1745 | EXPECT_EQ(169, env->GetArrayLength(reinterpret_cast<jarray>(o169))); |
| 1746 | EXPECT_EQ(170, env->GetArrayLength(reinterpret_cast<jarray>(o170))); |
| 1747 | EXPECT_EQ(171, env->GetArrayLength(reinterpret_cast<jarray>(o171))); |
| 1748 | EXPECT_EQ(172, env->GetArrayLength(reinterpret_cast<jarray>(o172))); |
| 1749 | EXPECT_EQ(173, env->GetArrayLength(reinterpret_cast<jarray>(o173))); |
| 1750 | EXPECT_EQ(174, env->GetArrayLength(reinterpret_cast<jarray>(o174))); |
| 1751 | EXPECT_EQ(175, env->GetArrayLength(reinterpret_cast<jarray>(o175))); |
| 1752 | EXPECT_EQ(176, env->GetArrayLength(reinterpret_cast<jarray>(o176))); |
| 1753 | EXPECT_EQ(177, env->GetArrayLength(reinterpret_cast<jarray>(o177))); |
| 1754 | EXPECT_EQ(178, env->GetArrayLength(reinterpret_cast<jarray>(o178))); |
| 1755 | EXPECT_EQ(179, env->GetArrayLength(reinterpret_cast<jarray>(o179))); |
| 1756 | EXPECT_EQ(180, env->GetArrayLength(reinterpret_cast<jarray>(o180))); |
| 1757 | EXPECT_EQ(181, env->GetArrayLength(reinterpret_cast<jarray>(o181))); |
| 1758 | EXPECT_EQ(182, env->GetArrayLength(reinterpret_cast<jarray>(o182))); |
| 1759 | EXPECT_EQ(183, env->GetArrayLength(reinterpret_cast<jarray>(o183))); |
| 1760 | EXPECT_EQ(184, env->GetArrayLength(reinterpret_cast<jarray>(o184))); |
| 1761 | EXPECT_EQ(185, env->GetArrayLength(reinterpret_cast<jarray>(o185))); |
| 1762 | EXPECT_EQ(186, env->GetArrayLength(reinterpret_cast<jarray>(o186))); |
| 1763 | EXPECT_EQ(187, env->GetArrayLength(reinterpret_cast<jarray>(o187))); |
| 1764 | EXPECT_EQ(188, env->GetArrayLength(reinterpret_cast<jarray>(o188))); |
| 1765 | EXPECT_EQ(189, env->GetArrayLength(reinterpret_cast<jarray>(o189))); |
| 1766 | EXPECT_EQ(190, env->GetArrayLength(reinterpret_cast<jarray>(o190))); |
| 1767 | EXPECT_EQ(191, env->GetArrayLength(reinterpret_cast<jarray>(o191))); |
| 1768 | EXPECT_EQ(192, env->GetArrayLength(reinterpret_cast<jarray>(o192))); |
| 1769 | EXPECT_EQ(193, env->GetArrayLength(reinterpret_cast<jarray>(o193))); |
| 1770 | EXPECT_EQ(194, env->GetArrayLength(reinterpret_cast<jarray>(o194))); |
| 1771 | EXPECT_EQ(195, env->GetArrayLength(reinterpret_cast<jarray>(o195))); |
| 1772 | EXPECT_EQ(196, env->GetArrayLength(reinterpret_cast<jarray>(o196))); |
| 1773 | EXPECT_EQ(197, env->GetArrayLength(reinterpret_cast<jarray>(o197))); |
| 1774 | EXPECT_EQ(198, env->GetArrayLength(reinterpret_cast<jarray>(o198))); |
| 1775 | EXPECT_EQ(199, env->GetArrayLength(reinterpret_cast<jarray>(o199))); |
| 1776 | EXPECT_EQ(200, env->GetArrayLength(reinterpret_cast<jarray>(o200))); |
| 1777 | EXPECT_EQ(201, env->GetArrayLength(reinterpret_cast<jarray>(o201))); |
| 1778 | EXPECT_EQ(202, env->GetArrayLength(reinterpret_cast<jarray>(o202))); |
| 1779 | EXPECT_EQ(203, env->GetArrayLength(reinterpret_cast<jarray>(o203))); |
| 1780 | EXPECT_EQ(204, env->GetArrayLength(reinterpret_cast<jarray>(o204))); |
| 1781 | EXPECT_EQ(205, env->GetArrayLength(reinterpret_cast<jarray>(o205))); |
| 1782 | EXPECT_EQ(206, env->GetArrayLength(reinterpret_cast<jarray>(o206))); |
| 1783 | EXPECT_EQ(207, env->GetArrayLength(reinterpret_cast<jarray>(o207))); |
| 1784 | EXPECT_EQ(208, env->GetArrayLength(reinterpret_cast<jarray>(o208))); |
| 1785 | EXPECT_EQ(209, env->GetArrayLength(reinterpret_cast<jarray>(o209))); |
| 1786 | EXPECT_EQ(210, env->GetArrayLength(reinterpret_cast<jarray>(o210))); |
| 1787 | EXPECT_EQ(211, env->GetArrayLength(reinterpret_cast<jarray>(o211))); |
| 1788 | EXPECT_EQ(212, env->GetArrayLength(reinterpret_cast<jarray>(o212))); |
| 1789 | EXPECT_EQ(213, env->GetArrayLength(reinterpret_cast<jarray>(o213))); |
| 1790 | EXPECT_EQ(214, env->GetArrayLength(reinterpret_cast<jarray>(o214))); |
| 1791 | EXPECT_EQ(215, env->GetArrayLength(reinterpret_cast<jarray>(o215))); |
| 1792 | EXPECT_EQ(216, env->GetArrayLength(reinterpret_cast<jarray>(o216))); |
| 1793 | EXPECT_EQ(217, env->GetArrayLength(reinterpret_cast<jarray>(o217))); |
| 1794 | EXPECT_EQ(218, env->GetArrayLength(reinterpret_cast<jarray>(o218))); |
| 1795 | EXPECT_EQ(219, env->GetArrayLength(reinterpret_cast<jarray>(o219))); |
| 1796 | EXPECT_EQ(220, env->GetArrayLength(reinterpret_cast<jarray>(o220))); |
| 1797 | EXPECT_EQ(221, env->GetArrayLength(reinterpret_cast<jarray>(o221))); |
| 1798 | EXPECT_EQ(222, env->GetArrayLength(reinterpret_cast<jarray>(o222))); |
| 1799 | EXPECT_EQ(223, env->GetArrayLength(reinterpret_cast<jarray>(o223))); |
| 1800 | EXPECT_EQ(224, env->GetArrayLength(reinterpret_cast<jarray>(o224))); |
| 1801 | EXPECT_EQ(225, env->GetArrayLength(reinterpret_cast<jarray>(o225))); |
| 1802 | EXPECT_EQ(226, env->GetArrayLength(reinterpret_cast<jarray>(o226))); |
| 1803 | EXPECT_EQ(227, env->GetArrayLength(reinterpret_cast<jarray>(o227))); |
| 1804 | EXPECT_EQ(228, env->GetArrayLength(reinterpret_cast<jarray>(o228))); |
| 1805 | EXPECT_EQ(229, env->GetArrayLength(reinterpret_cast<jarray>(o229))); |
| 1806 | EXPECT_EQ(230, env->GetArrayLength(reinterpret_cast<jarray>(o230))); |
| 1807 | EXPECT_EQ(231, env->GetArrayLength(reinterpret_cast<jarray>(o231))); |
| 1808 | EXPECT_EQ(232, env->GetArrayLength(reinterpret_cast<jarray>(o232))); |
| 1809 | EXPECT_EQ(233, env->GetArrayLength(reinterpret_cast<jarray>(o233))); |
| 1810 | EXPECT_EQ(234, env->GetArrayLength(reinterpret_cast<jarray>(o234))); |
| 1811 | EXPECT_EQ(235, env->GetArrayLength(reinterpret_cast<jarray>(o235))); |
| 1812 | EXPECT_EQ(236, env->GetArrayLength(reinterpret_cast<jarray>(o236))); |
| 1813 | EXPECT_EQ(237, env->GetArrayLength(reinterpret_cast<jarray>(o237))); |
| 1814 | EXPECT_EQ(238, env->GetArrayLength(reinterpret_cast<jarray>(o238))); |
| 1815 | EXPECT_EQ(239, env->GetArrayLength(reinterpret_cast<jarray>(o239))); |
| 1816 | EXPECT_EQ(240, env->GetArrayLength(reinterpret_cast<jarray>(o240))); |
| 1817 | EXPECT_EQ(241, env->GetArrayLength(reinterpret_cast<jarray>(o241))); |
| 1818 | EXPECT_EQ(242, env->GetArrayLength(reinterpret_cast<jarray>(o242))); |
| 1819 | EXPECT_EQ(243, env->GetArrayLength(reinterpret_cast<jarray>(o243))); |
| 1820 | EXPECT_EQ(244, env->GetArrayLength(reinterpret_cast<jarray>(o244))); |
| 1821 | EXPECT_EQ(245, env->GetArrayLength(reinterpret_cast<jarray>(o245))); |
| 1822 | EXPECT_EQ(246, env->GetArrayLength(reinterpret_cast<jarray>(o246))); |
| 1823 | EXPECT_EQ(247, env->GetArrayLength(reinterpret_cast<jarray>(o247))); |
| 1824 | EXPECT_EQ(248, env->GetArrayLength(reinterpret_cast<jarray>(o248))); |
| 1825 | EXPECT_EQ(249, env->GetArrayLength(reinterpret_cast<jarray>(o249))); |
| 1826 | EXPECT_EQ(250, env->GetArrayLength(reinterpret_cast<jarray>(o250))); |
| 1827 | EXPECT_EQ(251, env->GetArrayLength(reinterpret_cast<jarray>(o251))); |
| 1828 | EXPECT_EQ(252, env->GetArrayLength(reinterpret_cast<jarray>(o252))); |
| 1829 | EXPECT_EQ(253, env->GetArrayLength(reinterpret_cast<jarray>(o253))); |
| 1830 | } |
| 1831 | } |
| 1832 | |
| 1833 | const char* longSig = |
| 1834 | "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1835 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1836 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1837 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1838 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1839 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1840 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1841 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1842 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1843 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1844 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1845 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1846 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1847 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1848 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1849 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1850 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1851 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1852 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1853 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1854 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1855 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1856 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1857 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1858 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1859 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1860 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1861 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1862 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1863 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1864 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1865 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1866 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1867 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1868 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1869 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1870 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1871 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1872 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1873 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1874 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1875 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1876 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1877 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1878 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1879 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1880 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1881 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1882 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1883 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1884 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V"; |
| 1885 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1886 | void JniCompilerTest::MaxParamNumberImpl() { |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1887 | SetUpForTest(false, "maxParamNumber", longSig, |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1888 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_maxParamNumber)); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1889 | |
| 1890 | jvalue args[254]; |
| 1891 | |
| 1892 | // First test: test with all arguments null. |
| 1893 | for (int i = 0; i < 254; ++i) { |
| 1894 | args[i].l = nullptr; |
| 1895 | } |
| 1896 | |
| 1897 | env_->CallNonvirtualVoidMethodA(jobj_, jklass_, jmethod_, args); |
| 1898 | |
| 1899 | // Second test: test with int[] objects with increasing lengths |
| 1900 | for (int i = 0; i < 254; ++i) { |
| 1901 | jintArray tmp = env_->NewIntArray(i); |
| 1902 | args[i].l = tmp; |
| 1903 | EXPECT_NE(args[i].l, nullptr); |
| 1904 | } |
| 1905 | |
| 1906 | env_->CallNonvirtualVoidMethodA(jobj_, jklass_, jmethod_, args); |
| 1907 | } |
| 1908 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1909 | JNI_TEST(MaxParamNumber) |
| 1910 | |
| 1911 | void JniCompilerTest::WithoutImplementationImpl() { |
Andreas Gampe | 369810a | 2015-01-14 19:53:31 -0800 | [diff] [blame] | 1912 | // This will lead to error messages in the log. |
| 1913 | ScopedLogSeverity sls(LogSeverity::FATAL); |
| 1914 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1915 | SetUpForTest(false, "withoutImplementation", "()V", NORMAL_JNI_ONLY_NULLPTR); |
Andreas Gampe | ad61517 | 2014-04-04 16:20:13 -0700 | [diff] [blame] | 1916 | |
| 1917 | env_->CallVoidMethod(jobj_, jmethod_); |
| 1918 | |
| 1919 | EXPECT_TRUE(Thread::Current()->IsExceptionPending()); |
| 1920 | EXPECT_TRUE(env_->ExceptionCheck() == JNI_TRUE); |
| 1921 | } |
| 1922 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1923 | // TODO: Don't test @FastNative here since it goes through a stub lookup (unsupported) which would |
| 1924 | // normally fail with an exception, but fails with an assert. |
| 1925 | JNI_TEST_NORMAL_ONLY(WithoutImplementation) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1926 | |
Andreas Gampe | 48ee356 | 2015-04-10 19:57:29 -0700 | [diff] [blame] | 1927 | void JniCompilerTest::WithoutImplementationRefReturnImpl() { |
| 1928 | // This will lead to error messages in the log. |
| 1929 | ScopedLogSeverity sls(LogSeverity::FATAL); |
| 1930 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1931 | SetUpForTest(false, |
| 1932 | "withoutImplementationRefReturn", |
| 1933 | "()Ljava/lang/Object;", |
| 1934 | NORMAL_JNI_ONLY_NULLPTR); |
Andreas Gampe | 48ee356 | 2015-04-10 19:57:29 -0700 | [diff] [blame] | 1935 | |
| 1936 | env_->CallObjectMethod(jobj_, jmethod_); |
| 1937 | |
| 1938 | EXPECT_TRUE(Thread::Current()->IsExceptionPending()); |
| 1939 | EXPECT_TRUE(env_->ExceptionCheck() == JNI_TRUE); |
| 1940 | } |
| 1941 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1942 | // TODO: Should work for @FastNative too. |
| 1943 | JNI_TEST_NORMAL_ONLY(WithoutImplementationRefReturn) |
Andreas Gampe | 48ee356 | 2015-04-10 19:57:29 -0700 | [diff] [blame] | 1944 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 1945 | void Java_MyClassNatives_stackArgsIntsFirst(JNIEnv*, jclass, jint i1, jint i2, jint i3, |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1946 | jint i4, jint i5, jint i6, jint i7, jint i8, jint i9, |
| 1947 | jint i10, jfloat f1, jfloat f2, jfloat f3, jfloat f4, |
| 1948 | jfloat f5, jfloat f6, jfloat f7, jfloat f8, jfloat f9, |
| 1949 | jfloat f10) { |
| 1950 | EXPECT_EQ(i1, 1); |
| 1951 | EXPECT_EQ(i2, 2); |
| 1952 | EXPECT_EQ(i3, 3); |
| 1953 | EXPECT_EQ(i4, 4); |
| 1954 | EXPECT_EQ(i5, 5); |
| 1955 | EXPECT_EQ(i6, 6); |
| 1956 | EXPECT_EQ(i7, 7); |
| 1957 | EXPECT_EQ(i8, 8); |
| 1958 | EXPECT_EQ(i9, 9); |
| 1959 | EXPECT_EQ(i10, 10); |
| 1960 | |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1961 | jint i11 = bit_cast<jint, jfloat>(f1); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1962 | EXPECT_EQ(i11, 11); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1963 | jint i12 = bit_cast<jint, jfloat>(f2); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1964 | EXPECT_EQ(i12, 12); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1965 | jint i13 = bit_cast<jint, jfloat>(f3); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1966 | EXPECT_EQ(i13, 13); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1967 | jint i14 = bit_cast<jint, jfloat>(f4); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1968 | EXPECT_EQ(i14, 14); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1969 | jint i15 = bit_cast<jint, jfloat>(f5); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1970 | EXPECT_EQ(i15, 15); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1971 | jint i16 = bit_cast<jint, jfloat>(f6); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1972 | EXPECT_EQ(i16, 16); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1973 | jint i17 = bit_cast<jint, jfloat>(f7); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1974 | EXPECT_EQ(i17, 17); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1975 | jint i18 = bit_cast<jint, jfloat>(f8); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1976 | EXPECT_EQ(i18, 18); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1977 | jint i19 = bit_cast<jint, jfloat>(f9); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1978 | EXPECT_EQ(i19, 19); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1979 | jint i20 = bit_cast<jint, jfloat>(f10); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1980 | EXPECT_EQ(i20, 20); |
| 1981 | } |
| 1982 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1983 | void JniCompilerTest::StackArgsIntsFirstImpl() { |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1984 | SetUpForTest(true, "stackArgsIntsFirst", "(IIIIIIIIIIFFFFFFFFFF)V", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 1985 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_stackArgsIntsFirst)); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1986 | |
| 1987 | jint i1 = 1; |
| 1988 | jint i2 = 2; |
| 1989 | jint i3 = 3; |
| 1990 | jint i4 = 4; |
| 1991 | jint i5 = 5; |
| 1992 | jint i6 = 6; |
| 1993 | jint i7 = 7; |
| 1994 | jint i8 = 8; |
| 1995 | jint i9 = 9; |
| 1996 | jint i10 = 10; |
| 1997 | |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1998 | jfloat f1 = bit_cast<jfloat, jint>(11); |
| 1999 | jfloat f2 = bit_cast<jfloat, jint>(12); |
| 2000 | jfloat f3 = bit_cast<jfloat, jint>(13); |
| 2001 | jfloat f4 = bit_cast<jfloat, jint>(14); |
| 2002 | jfloat f5 = bit_cast<jfloat, jint>(15); |
| 2003 | jfloat f6 = bit_cast<jfloat, jint>(16); |
| 2004 | jfloat f7 = bit_cast<jfloat, jint>(17); |
| 2005 | jfloat f8 = bit_cast<jfloat, jint>(18); |
| 2006 | jfloat f9 = bit_cast<jfloat, jint>(19); |
| 2007 | jfloat f10 = bit_cast<jfloat, jint>(20); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2008 | |
| 2009 | env_->CallStaticVoidMethod(jklass_, jmethod_, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, f1, f2, |
| 2010 | f3, f4, f5, f6, f7, f8, f9, f10); |
| 2011 | } |
| 2012 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 2013 | JNI_TEST_CRITICAL(StackArgsIntsFirst) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 2014 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 2015 | void Java_MyClassNatives_stackArgsFloatsFirst(JNIEnv*, jclass, jfloat f1, jfloat f2, |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2016 | jfloat f3, jfloat f4, jfloat f5, jfloat f6, jfloat f7, |
| 2017 | jfloat f8, jfloat f9, jfloat f10, jint i1, jint i2, |
| 2018 | jint i3, jint i4, jint i5, jint i6, jint i7, jint i8, |
| 2019 | jint i9, jint i10) { |
| 2020 | EXPECT_EQ(i1, 1); |
| 2021 | EXPECT_EQ(i2, 2); |
| 2022 | EXPECT_EQ(i3, 3); |
| 2023 | EXPECT_EQ(i4, 4); |
| 2024 | EXPECT_EQ(i5, 5); |
| 2025 | EXPECT_EQ(i6, 6); |
| 2026 | EXPECT_EQ(i7, 7); |
| 2027 | EXPECT_EQ(i8, 8); |
| 2028 | EXPECT_EQ(i9, 9); |
| 2029 | EXPECT_EQ(i10, 10); |
| 2030 | |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2031 | jint i11 = bit_cast<jint, jfloat>(f1); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2032 | EXPECT_EQ(i11, 11); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2033 | jint i12 = bit_cast<jint, jfloat>(f2); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2034 | EXPECT_EQ(i12, 12); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2035 | jint i13 = bit_cast<jint, jfloat>(f3); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2036 | EXPECT_EQ(i13, 13); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2037 | jint i14 = bit_cast<jint, jfloat>(f4); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2038 | EXPECT_EQ(i14, 14); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2039 | jint i15 = bit_cast<jint, jfloat>(f5); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2040 | EXPECT_EQ(i15, 15); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2041 | jint i16 = bit_cast<jint, jfloat>(f6); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2042 | EXPECT_EQ(i16, 16); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2043 | jint i17 = bit_cast<jint, jfloat>(f7); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2044 | EXPECT_EQ(i17, 17); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2045 | jint i18 = bit_cast<jint, jfloat>(f8); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2046 | EXPECT_EQ(i18, 18); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2047 | jint i19 = bit_cast<jint, jfloat>(f9); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2048 | EXPECT_EQ(i19, 19); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2049 | jint i20 = bit_cast<jint, jfloat>(f10); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2050 | EXPECT_EQ(i20, 20); |
| 2051 | } |
| 2052 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 2053 | void JniCompilerTest::StackArgsFloatsFirstImpl() { |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2054 | SetUpForTest(true, "stackArgsFloatsFirst", "(FFFFFFFFFFIIIIIIIIII)V", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 2055 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_stackArgsFloatsFirst)); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2056 | |
| 2057 | jint i1 = 1; |
| 2058 | jint i2 = 2; |
| 2059 | jint i3 = 3; |
| 2060 | jint i4 = 4; |
| 2061 | jint i5 = 5; |
| 2062 | jint i6 = 6; |
| 2063 | jint i7 = 7; |
| 2064 | jint i8 = 8; |
| 2065 | jint i9 = 9; |
| 2066 | jint i10 = 10; |
| 2067 | |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2068 | jfloat f1 = bit_cast<jfloat, jint>(11); |
| 2069 | jfloat f2 = bit_cast<jfloat, jint>(12); |
| 2070 | jfloat f3 = bit_cast<jfloat, jint>(13); |
| 2071 | jfloat f4 = bit_cast<jfloat, jint>(14); |
| 2072 | jfloat f5 = bit_cast<jfloat, jint>(15); |
| 2073 | jfloat f6 = bit_cast<jfloat, jint>(16); |
| 2074 | jfloat f7 = bit_cast<jfloat, jint>(17); |
| 2075 | jfloat f8 = bit_cast<jfloat, jint>(18); |
| 2076 | jfloat f9 = bit_cast<jfloat, jint>(19); |
| 2077 | jfloat f10 = bit_cast<jfloat, jint>(20); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2078 | |
| 2079 | env_->CallStaticVoidMethod(jklass_, jmethod_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, i1, i2, i3, |
| 2080 | i4, i5, i6, i7, i8, i9, i10); |
| 2081 | } |
| 2082 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 2083 | JNI_TEST_CRITICAL(StackArgsFloatsFirst) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 2084 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 2085 | void Java_MyClassNatives_stackArgsMixed(JNIEnv*, jclass, jint i1, jfloat f1, jint i2, |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2086 | jfloat f2, jint i3, jfloat f3, jint i4, jfloat f4, jint i5, |
| 2087 | jfloat f5, jint i6, jfloat f6, jint i7, jfloat f7, jint i8, |
| 2088 | jfloat f8, jint i9, jfloat f9, jint i10, jfloat f10) { |
| 2089 | EXPECT_EQ(i1, 1); |
| 2090 | EXPECT_EQ(i2, 2); |
| 2091 | EXPECT_EQ(i3, 3); |
| 2092 | EXPECT_EQ(i4, 4); |
| 2093 | EXPECT_EQ(i5, 5); |
| 2094 | EXPECT_EQ(i6, 6); |
| 2095 | EXPECT_EQ(i7, 7); |
| 2096 | EXPECT_EQ(i8, 8); |
| 2097 | EXPECT_EQ(i9, 9); |
| 2098 | EXPECT_EQ(i10, 10); |
| 2099 | |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2100 | jint i11 = bit_cast<jint, jfloat>(f1); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2101 | EXPECT_EQ(i11, 11); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2102 | jint i12 = bit_cast<jint, jfloat>(f2); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2103 | EXPECT_EQ(i12, 12); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2104 | jint i13 = bit_cast<jint, jfloat>(f3); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2105 | EXPECT_EQ(i13, 13); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2106 | jint i14 = bit_cast<jint, jfloat>(f4); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2107 | EXPECT_EQ(i14, 14); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2108 | jint i15 = bit_cast<jint, jfloat>(f5); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2109 | EXPECT_EQ(i15, 15); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2110 | jint i16 = bit_cast<jint, jfloat>(f6); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2111 | EXPECT_EQ(i16, 16); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2112 | jint i17 = bit_cast<jint, jfloat>(f7); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2113 | EXPECT_EQ(i17, 17); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2114 | jint i18 = bit_cast<jint, jfloat>(f8); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2115 | EXPECT_EQ(i18, 18); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2116 | jint i19 = bit_cast<jint, jfloat>(f9); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2117 | EXPECT_EQ(i19, 19); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2118 | jint i20 = bit_cast<jint, jfloat>(f10); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2119 | EXPECT_EQ(i20, 20); |
| 2120 | } |
| 2121 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 2122 | void JniCompilerTest::StackArgsMixedImpl() { |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2123 | SetUpForTest(true, "stackArgsMixed", "(IFIFIFIFIFIFIFIFIFIF)V", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 2124 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_stackArgsMixed)); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2125 | |
| 2126 | jint i1 = 1; |
| 2127 | jint i2 = 2; |
| 2128 | jint i3 = 3; |
| 2129 | jint i4 = 4; |
| 2130 | jint i5 = 5; |
| 2131 | jint i6 = 6; |
| 2132 | jint i7 = 7; |
| 2133 | jint i8 = 8; |
| 2134 | jint i9 = 9; |
| 2135 | jint i10 = 10; |
| 2136 | |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 2137 | jfloat f1 = bit_cast<jfloat, jint>(11); |
| 2138 | jfloat f2 = bit_cast<jfloat, jint>(12); |
| 2139 | jfloat f3 = bit_cast<jfloat, jint>(13); |
| 2140 | jfloat f4 = bit_cast<jfloat, jint>(14); |
| 2141 | jfloat f5 = bit_cast<jfloat, jint>(15); |
| 2142 | jfloat f6 = bit_cast<jfloat, jint>(16); |
| 2143 | jfloat f7 = bit_cast<jfloat, jint>(17); |
| 2144 | jfloat f8 = bit_cast<jfloat, jint>(18); |
| 2145 | jfloat f9 = bit_cast<jfloat, jint>(19); |
| 2146 | jfloat f10 = bit_cast<jfloat, jint>(20); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 2147 | |
| 2148 | env_->CallStaticVoidMethod(jklass_, jmethod_, i1, f1, i2, f2, i3, f3, i4, f4, i5, f5, i6, f6, i7, |
| 2149 | f7, i8, f8, i9, f9, i10, f10); |
| 2150 | } |
| 2151 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 2152 | JNI_TEST_CRITICAL(StackArgsMixed) |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 2153 | |
Lazar Trsic | f652d60 | 2015-06-24 16:30:21 +0200 | [diff] [blame] | 2154 | #if defined(__mips__) && defined(__LP64__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) |
Pavle Batuta | 837e72a | 2016-03-16 11:31:46 +0100 | [diff] [blame] | 2155 | // Function will fetch the last argument passed from caller that is now on top of the stack and |
| 2156 | // return it as a 8B long. That way we can test if the caller has properly sign-extended the |
| 2157 | // value when placing it on the stack. |
| 2158 | __attribute__((naked)) |
| 2159 | jlong Java_MyClassNatives_getStackArgSignExtendedMips64( |
| 2160 | JNIEnv*, jclass, // Arguments passed from caller |
| 2161 | jint, jint, jint, jint, jint, jint, // through regs a0 to a7. |
| 2162 | jint) { // The last argument will be passed on the stack. |
| 2163 | __asm__( |
| 2164 | ".set noreorder\n\t" // Just return and store 8 bytes from the top of the stack |
| 2165 | "jr $ra\n\t" // in v0 (in branch delay slot). This should be the last |
| 2166 | "ld $v0, 0($sp)\n\t"); // argument. It is a 32-bit int, but it should be sign |
| 2167 | // extended and it occupies 64-bit location. |
Lazar Trsic | f652d60 | 2015-06-24 16:30:21 +0200 | [diff] [blame] | 2168 | } |
| 2169 | |
| 2170 | void JniCompilerTest::StackArgsSignExtendedMips64Impl() { |
Pavle Batuta | 837e72a | 2016-03-16 11:31:46 +0100 | [diff] [blame] | 2171 | uint64_t ret; |
| 2172 | SetUpForTest(true, |
| 2173 | "getStackArgSignExtendedMips64", |
| 2174 | "(IIIIIII)J", |
| 2175 | // Don't use wrapper because this is raw assembly function. |
| 2176 | reinterpret_cast<void*>(&Java_MyClassNatives_getStackArgSignExtendedMips64)); |
Lazar Trsic | f652d60 | 2015-06-24 16:30:21 +0200 | [diff] [blame] | 2177 | |
Pavle Batuta | 837e72a | 2016-03-16 11:31:46 +0100 | [diff] [blame] | 2178 | // Mips64 ABI requires that arguments passed through stack be sign-extended 8B slots. |
| 2179 | // First 8 arguments are passed through registers. |
| 2180 | // Final argument's value is 7. When sign-extended, higher stack bits should be 0. |
| 2181 | ret = env_->CallStaticLongMethod(jklass_, jmethod_, 1, 2, 3, 4, 5, 6, 7); |
| 2182 | EXPECT_EQ(High32Bits(ret), static_cast<uint32_t>(0)); |
| 2183 | |
| 2184 | // Final argument's value is -8. When sign-extended, higher stack bits should be 0xffffffff. |
| 2185 | ret = env_->CallStaticLongMethod(jklass_, jmethod_, 1, 2, 3, 4, 5, 6, -8); |
| 2186 | EXPECT_EQ(High32Bits(ret), static_cast<uint32_t>(0xffffffff)); |
Lazar Trsic | f652d60 | 2015-06-24 16:30:21 +0200 | [diff] [blame] | 2187 | } |
| 2188 | |
Pavle Batuta | 837e72a | 2016-03-16 11:31:46 +0100 | [diff] [blame] | 2189 | JNI_TEST(StackArgsSignExtendedMips64) |
| 2190 | #endif |
Lazar Trsic | f652d60 | 2015-06-24 16:30:21 +0200 | [diff] [blame] | 2191 | |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 2192 | void Java_MyClassNatives_normalNative(JNIEnv*, jclass) { |
| 2193 | // Intentionally left empty. |
| 2194 | } |
| 2195 | |
| 2196 | // Methods not annotated with anything are not considered "fast native" |
| 2197 | // -- Check that the annotation lookup does not find it. |
| 2198 | void JniCompilerTest::NormalNativeImpl() { |
| 2199 | SetUpForTest(/* direct */ true, |
| 2200 | "normalNative", |
| 2201 | "()V", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 2202 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_normalNative)); |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 2203 | |
Andreas Gampe | 13b2784 | 2016-11-07 16:48:23 -0800 | [diff] [blame] | 2204 | ArtMethod* method = jni::DecodeArtMethod(jmethod_); |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 2205 | ASSERT_TRUE(method != nullptr); |
| 2206 | |
Vladimir Marko | b0a6aee | 2017-10-27 10:34:04 +0100 | [diff] [blame] | 2207 | EXPECT_FALSE(method->IsCriticalNative()); |
| 2208 | EXPECT_FALSE(method->IsFastNative()); |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 2209 | } |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 2210 | |
| 2211 | // TODO: just rename the java functions to the standard convention and remove duplicated tests |
| 2212 | JNI_TEST_NORMAL_ONLY(NormalNative) |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 2213 | |
| 2214 | // Methods annotated with @FastNative are considered "fast native" |
| 2215 | // -- Check that the annotation lookup succeeds. |
| 2216 | void Java_MyClassNatives_fastNative(JNIEnv*, jclass) { |
| 2217 | // Intentionally left empty. |
| 2218 | } |
| 2219 | |
| 2220 | void JniCompilerTest::FastNativeImpl() { |
| 2221 | SetUpForTest(/* direct */ true, |
| 2222 | "fastNative", |
| 2223 | "()V", |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 2224 | CURRENT_JNI_WRAPPER(Java_MyClassNatives_fastNative)); |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 2225 | |
Andreas Gampe | 13b2784 | 2016-11-07 16:48:23 -0800 | [diff] [blame] | 2226 | ArtMethod* method = jni::DecodeArtMethod(jmethod_); |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 2227 | ASSERT_TRUE(method != nullptr); |
| 2228 | |
Vladimir Marko | b0a6aee | 2017-10-27 10:34:04 +0100 | [diff] [blame] | 2229 | EXPECT_FALSE(method->IsCriticalNative()); |
| 2230 | EXPECT_TRUE(method->IsFastNative()); |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 2231 | } |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 2232 | |
| 2233 | // TODO: just rename the java functions to the standard convention and remove duplicated tests |
| 2234 | JNI_TEST_NORMAL_ONLY(FastNative) |
| 2235 | |
| 2236 | int gJava_myClassNatives_criticalNative_calls[kJniKindCount] = {}; |
| 2237 | // Methods annotated with @CriticalNative are considered "critical native" |
| 2238 | // -- Check that the annotation lookup succeeds. |
| 2239 | void Java_MyClassNatives_criticalNative() { |
| 2240 | gJava_myClassNatives_criticalNative_calls[gCurrentJni]++; |
| 2241 | } |
| 2242 | |
| 2243 | void JniCompilerTest::CriticalNativeImpl() { |
| 2244 | SetUpForTest(/* direct */ true, |
| 2245 | // Important: Don't change the "current jni" yet to avoid a method name suffix. |
| 2246 | "criticalNative", |
| 2247 | "()V", |
| 2248 | // TODO: Use CURRENT_JNI_WRAPPER instead which is more generic. |
| 2249 | reinterpret_cast<void*>(&Java_MyClassNatives_criticalNative)); |
| 2250 | |
| 2251 | // TODO: remove this manual updating of the current JNI. Merge with the other tests. |
| 2252 | UpdateCurrentJni(JniKind::kCritical); |
| 2253 | ASSERT_TRUE(IsCurrentJniCritical()); |
| 2254 | |
Andreas Gampe | 13b2784 | 2016-11-07 16:48:23 -0800 | [diff] [blame] | 2255 | ArtMethod* method = jni::DecodeArtMethod(jmethod_); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 2256 | ASSERT_TRUE(method != nullptr); |
| 2257 | |
Vladimir Marko | b0a6aee | 2017-10-27 10:34:04 +0100 | [diff] [blame] | 2258 | EXPECT_TRUE(method->IsCriticalNative()); |
| 2259 | EXPECT_FALSE(method->IsFastNative()); |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 2260 | |
| 2261 | EXPECT_EQ(0, gJava_myClassNatives_criticalNative_calls[gCurrentJni]); |
| 2262 | env_->CallStaticVoidMethod(jklass_, jmethod_); |
| 2263 | EXPECT_EQ(1, gJava_myClassNatives_criticalNative_calls[gCurrentJni]); |
| 2264 | |
| 2265 | gJava_myClassNatives_criticalNative_calls[gCurrentJni] = 0; |
| 2266 | } |
| 2267 | |
| 2268 | // TODO: just rename the java functions to the standard convention and remove duplicated tests |
| 2269 | JNI_TEST_NORMAL_ONLY(CriticalNative) |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 2270 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 2271 | } // namespace art |