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> |
| 18 | |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 19 | #include <math.h> |
| 20 | |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 21 | #include "class_linker.h" |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 22 | #include "common_compiler_test.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 23 | #include "dex_file.h" |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 24 | #include "gtest/gtest.h" |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 25 | #include "indirect_reference_table.h" |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 26 | #include "jni_internal.h" |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 27 | #include "mem_map.h" |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 28 | #include "mirror/art_method-inl.h" |
Ian Rogers | 4f6ad8a | 2013-03-18 15:27:28 -0700 | [diff] [blame] | 29 | #include "mirror/class-inl.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 30 | #include "mirror/class_loader.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 31 | #include "mirror/object_array-inl.h" |
Ian Rogers | 04d7aa9 | 2013-03-16 14:29:17 -0700 | [diff] [blame] | 32 | #include "mirror/object-inl.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 33 | #include "mirror/stack_trace_element.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 34 | #include "runtime.h" |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 35 | #include "ScopedLocalRef.h" |
| 36 | #include "scoped_thread_state_change.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 37 | #include "thread.h" |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 38 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 39 | extern "C" JNIEXPORT jint JNICALL Java_MyClassNatives_bar(JNIEnv*, jobject, jint count) { |
Brian Carlstrom | b9cc1ca | 2012-01-27 00:57:42 -0800 | [diff] [blame] | 40 | return count + 1; |
| 41 | } |
| 42 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 43 | extern "C" JNIEXPORT jint JNICALL Java_MyClassNatives_sbar(JNIEnv*, jclass, jint count) { |
Ian Rogers | 1cefdbd | 2012-02-29 09:34:50 -0800 | [diff] [blame] | 44 | return count + 1; |
| 45 | } |
| 46 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 47 | namespace art { |
| 48 | |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 49 | class JniCompilerTest : public CommonCompilerTest { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 50 | protected: |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 51 | void SetUp() OVERRIDE { |
| 52 | CommonCompilerTest::SetUp(); |
| 53 | check_generic_jni_ = false; |
| 54 | } |
| 55 | |
| 56 | void SetCheckGenericJni(bool generic) { |
| 57 | check_generic_jni_ = generic; |
| 58 | } |
| 59 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 60 | void CompileForTest(jobject class_loader, bool direct, |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 61 | const char* method_name, const char* method_sig) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 62 | ScopedObjectAccess soa(Thread::Current()); |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 63 | StackHandleScope<1> hs(soa.Self()); |
| 64 | Handle<mirror::ClassLoader> loader( |
| 65 | hs.NewHandle(soa.Decode<mirror::ClassLoader*>(class_loader))); |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 66 | // Compile the native method before starting the runtime |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 67 | mirror::Class* c = class_linker_->FindClass(soa.Self(), "LMyClassNatives;", loader); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 68 | mirror::ArtMethod* method; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 69 | if (direct) { |
buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 70 | method = c->FindDirectMethod(method_name, method_sig); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 71 | } else { |
buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 72 | method = c->FindVirtualMethod(method_name, method_sig); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 73 | } |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 74 | ASSERT_TRUE(method != nullptr) << method_name << " " << method_sig; |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 75 | if (check_generic_jni_) { |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 76 | method->SetEntryPointFromQuickCompiledCode(class_linker_->GetRuntimeQuickGenericJniStub()); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 77 | } else { |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 78 | const void* code = method->GetEntryPointFromQuickCompiledCode(); |
| 79 | if (code == nullptr || class_linker_->IsQuickGenericJniStub(code)) { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 80 | CompileMethod(method); |
| 81 | ASSERT_TRUE(method->GetEntryPointFromQuickCompiledCode() != nullptr) |
| 82 | << method_name << " " << method_sig; |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 83 | } |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 84 | } |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 85 | } |
| 86 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 87 | void SetUpForTest(bool direct, const char* method_name, const char* method_sig, |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 88 | void* native_fnptr) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 89 | // Initialize class loader and compile method when runtime not started. |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 90 | if (!runtime_->IsStarted()) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 91 | { |
| 92 | ScopedObjectAccess soa(Thread::Current()); |
| 93 | class_loader_ = LoadDex("MyClassNatives"); |
| 94 | } |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 95 | CompileForTest(class_loader_, direct, method_name, method_sig); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 96 | // Start runtime. |
| 97 | Thread::Current()->TransitionFromSuspendedToRunnable(); |
Brian Carlstrom | bd86bcc | 2013-03-10 20:26:16 -0700 | [diff] [blame] | 98 | bool started = runtime_->Start(); |
| 99 | CHECK(started); |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 100 | } |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 101 | // JNI operations after runtime start. |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 102 | env_ = Thread::Current()->GetJniEnv(); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 103 | jklass_ = env_->FindClass("MyClassNatives"); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 104 | ASSERT_TRUE(jklass_ != nullptr) << method_name << " " << method_sig; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 105 | |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 106 | if (direct) { |
| 107 | jmethod_ = env_->GetStaticMethodID(jklass_, method_name, method_sig); |
| 108 | } else { |
| 109 | jmethod_ = env_->GetMethodID(jklass_, method_name, method_sig); |
| 110 | } |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 111 | ASSERT_TRUE(jmethod_ != nullptr) << method_name << " " << method_sig; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 112 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 113 | if (native_fnptr != nullptr) { |
Elliott Hughes | b25c3f6 | 2012-03-26 16:35:06 -0700 | [diff] [blame] | 114 | JNINativeMethod methods[] = { { method_name, method_sig, native_fnptr } }; |
Brian Carlstrom | fc7120c | 2012-08-27 13:43:25 -0700 | [diff] [blame] | 115 | ASSERT_EQ(JNI_OK, env_->RegisterNatives(jklass_, methods, 1)) |
| 116 | << method_name << " " << method_sig; |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 117 | } else { |
| 118 | env_->UnregisterNatives(jklass_); |
Shih-wei Liao | 31384c5 | 2011-09-06 15:27:45 -0700 | [diff] [blame] | 119 | } |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 120 | |
| 121 | jmethodID constructor = env_->GetMethodID(jklass_, "<init>", "()V"); |
| 122 | jobj_ = env_->NewObject(jklass_, constructor); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 123 | ASSERT_TRUE(jobj_ != nullptr) << method_name << " " << method_sig; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 124 | } |
| 125 | |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 126 | public: |
| 127 | static jclass jklass_; |
| 128 | static jobject jobj_; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 129 | static jobject class_loader_; |
| 130 | |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 131 | protected: |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 132 | // We have to list the methods here so we can share them between default and generic JNI. |
| 133 | void CompileAndRunNoArgMethodImpl(); |
| 134 | void CompileAndRunIntMethodThroughStubImpl(); |
| 135 | void CompileAndRunStaticIntMethodThroughStubImpl(); |
| 136 | void CompileAndRunIntMethodImpl(); |
| 137 | void CompileAndRunIntIntMethodImpl(); |
| 138 | void CompileAndRunLongLongMethodImpl(); |
| 139 | void CompileAndRunDoubleDoubleMethodImpl(); |
| 140 | void CompileAndRun_fooJJ_synchronizedImpl(); |
| 141 | void CompileAndRunIntObjectObjectMethodImpl(); |
| 142 | void CompileAndRunStaticIntIntMethodImpl(); |
| 143 | void CompileAndRunStaticDoubleDoubleMethodImpl(); |
| 144 | void RunStaticLogDoubleMethodImpl(); |
| 145 | void RunStaticLogFloatMethodImpl(); |
| 146 | void RunStaticReturnTrueImpl(); |
| 147 | void RunStaticReturnFalseImpl(); |
| 148 | void RunGenericStaticReturnIntImpl(); |
| 149 | void CompileAndRunStaticIntObjectObjectMethodImpl(); |
| 150 | void CompileAndRunStaticSynchronizedIntObjectObjectMethodImpl(); |
| 151 | void ExceptionHandlingImpl(); |
| 152 | void NativeStackTraceElementImpl(); |
| 153 | void ReturnGlobalRefImpl(); |
| 154 | void LocalReferenceTableClearingTestImpl(); |
| 155 | void JavaLangSystemArrayCopyImpl(); |
| 156 | void CompareAndSwapIntImpl(); |
| 157 | void GetTextImpl(); |
| 158 | void GetSinkPropertiesNativeImpl(); |
| 159 | void UpcallReturnTypeChecking_InstanceImpl(); |
| 160 | void UpcallReturnTypeChecking_StaticImpl(); |
| 161 | void UpcallArgumentTypeChecking_InstanceImpl(); |
| 162 | void UpcallArgumentTypeChecking_StaticImpl(); |
| 163 | void CompileAndRunFloatFloatMethodImpl(); |
| 164 | void CheckParameterAlignImpl(); |
| 165 | void MaxParamNumberImpl(); |
| 166 | void WithoutImplementationImpl(); |
| 167 | void StackArgsIntsFirstImpl(); |
| 168 | void StackArgsFloatsFirstImpl(); |
| 169 | void StackArgsMixedImpl(); |
| 170 | |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 171 | JNIEnv* env_; |
| 172 | jmethodID jmethod_; |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 173 | bool check_generic_jni_; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 174 | }; |
| 175 | |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 176 | jclass JniCompilerTest::jklass_; |
| 177 | jobject JniCompilerTest::jobj_; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 178 | jobject JniCompilerTest::class_loader_; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 179 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 180 | #define JNI_TEST(TestName) \ |
| 181 | TEST_F(JniCompilerTest, TestName ## Default) { \ |
| 182 | TestName ## Impl(); \ |
| 183 | } \ |
| 184 | \ |
| 185 | TEST_F(JniCompilerTest, TestName ## Generic) { \ |
| 186 | TEST_DISABLED_FOR_MIPS(); \ |
| 187 | SetCheckGenericJni(true); \ |
| 188 | TestName ## Impl(); \ |
| 189 | } |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 190 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 191 | int gJava_MyClassNatives_foo_calls = 0; |
| 192 | void Java_MyClassNatives_foo(JNIEnv* env, jobject thisObj) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 193 | // 1 = thisObj |
Ian Rogers | 50b35e2 | 2012-10-04 10:09:15 -0700 | [diff] [blame] | 194 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
| 195 | Locks::mutator_lock_->AssertNotHeld(Thread::Current()); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 196 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 197 | EXPECT_TRUE(thisObj != nullptr); |
Ian Rogers | a8cd9f4 | 2011-08-19 16:43:41 -0700 | [diff] [blame] | 198 | EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 199 | gJava_MyClassNatives_foo_calls++; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 200 | ScopedObjectAccess soa(Thread::Current()); |
| 201 | EXPECT_EQ(1U, Thread::Current()->NumStackReferences()); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 202 | } |
| 203 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 204 | void JniCompilerTest::CompileAndRunNoArgMethodImpl() { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 205 | SetUpForTest(false, "foo", "()V", reinterpret_cast<void*>(&Java_MyClassNatives_foo)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 206 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 207 | EXPECT_EQ(0, gJava_MyClassNatives_foo_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 208 | env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 209 | EXPECT_EQ(1, gJava_MyClassNatives_foo_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 210 | env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 211 | EXPECT_EQ(2, gJava_MyClassNatives_foo_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 212 | |
| 213 | gJava_MyClassNatives_foo_calls = 0; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 214 | } |
| 215 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 216 | JNI_TEST(CompileAndRunNoArgMethod) |
| 217 | |
| 218 | void JniCompilerTest::CompileAndRunIntMethodThroughStubImpl() { |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 219 | SetUpForTest(false, "bar", "(I)I", nullptr); |
| 220 | // calling through stub will link with &Java_MyClassNatives_bar |
Shih-wei Liao | 31384c5 | 2011-09-06 15:27:45 -0700 | [diff] [blame] | 221 | |
Shih-wei Liao | 31384c5 | 2011-09-06 15:27:45 -0700 | [diff] [blame] | 222 | std::string reason; |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 223 | ASSERT_TRUE(Runtime::Current()->GetJavaVM()->LoadNativeLibrary(env_, "", class_loader_, &reason)) |
| 224 | << reason; |
Shih-wei Liao | 31384c5 | 2011-09-06 15:27:45 -0700 | [diff] [blame] | 225 | |
| 226 | jint result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 24); |
| 227 | EXPECT_EQ(25, result); |
| 228 | } |
| 229 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 230 | JNI_TEST(CompileAndRunIntMethodThroughStub) |
| 231 | |
| 232 | void JniCompilerTest::CompileAndRunStaticIntMethodThroughStubImpl() { |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 233 | SetUpForTest(true, "sbar", "(I)I", nullptr); |
| 234 | // calling through stub will link with &Java_MyClassNatives_sbar |
Ian Rogers | 1cefdbd | 2012-02-29 09:34:50 -0800 | [diff] [blame] | 235 | |
| 236 | std::string reason; |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 237 | ASSERT_TRUE(Runtime::Current()->GetJavaVM()->LoadNativeLibrary(env_, "", class_loader_, &reason)) |
| 238 | << reason; |
Ian Rogers | 1cefdbd | 2012-02-29 09:34:50 -0800 | [diff] [blame] | 239 | |
| 240 | jint result = env_->CallStaticIntMethod(jklass_, jmethod_, 42); |
| 241 | EXPECT_EQ(43, result); |
| 242 | } |
| 243 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 244 | JNI_TEST(CompileAndRunStaticIntMethodThroughStub) |
| 245 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 246 | int gJava_MyClassNatives_fooI_calls = 0; |
| 247 | jint Java_MyClassNatives_fooI(JNIEnv* env, jobject thisObj, jint x) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 248 | // 1 = thisObj |
Ian Rogers | 50b35e2 | 2012-10-04 10:09:15 -0700 | [diff] [blame] | 249 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 250 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 251 | EXPECT_TRUE(thisObj != nullptr); |
Ian Rogers | a8cd9f4 | 2011-08-19 16:43:41 -0700 | [diff] [blame] | 252 | EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 253 | gJava_MyClassNatives_fooI_calls++; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 254 | ScopedObjectAccess soa(Thread::Current()); |
| 255 | EXPECT_EQ(1U, Thread::Current()->NumStackReferences()); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 256 | return x; |
| 257 | } |
| 258 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 259 | void JniCompilerTest::CompileAndRunIntMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 260 | SetUpForTest(false, "fooI", "(I)I", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 261 | reinterpret_cast<void*>(&Java_MyClassNatives_fooI)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 262 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 263 | EXPECT_EQ(0, gJava_MyClassNatives_fooI_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 264 | jint result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 42); |
| 265 | EXPECT_EQ(42, result); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 266 | EXPECT_EQ(1, gJava_MyClassNatives_fooI_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 267 | result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 0xCAFED00D); |
| 268 | EXPECT_EQ(static_cast<jint>(0xCAFED00D), result); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 269 | EXPECT_EQ(2, gJava_MyClassNatives_fooI_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 270 | |
| 271 | gJava_MyClassNatives_fooI_calls = 0; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 272 | } |
| 273 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 274 | JNI_TEST(CompileAndRunIntMethod) |
| 275 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 276 | int gJava_MyClassNatives_fooII_calls = 0; |
| 277 | jint Java_MyClassNatives_fooII(JNIEnv* env, jobject thisObj, jint x, jint y) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 278 | // 1 = thisObj |
Ian Rogers | 50b35e2 | 2012-10-04 10:09:15 -0700 | [diff] [blame] | 279 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 280 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 281 | EXPECT_TRUE(thisObj != nullptr); |
Ian Rogers | a8cd9f4 | 2011-08-19 16:43:41 -0700 | [diff] [blame] | 282 | EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 283 | gJava_MyClassNatives_fooII_calls++; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 284 | ScopedObjectAccess soa(Thread::Current()); |
| 285 | EXPECT_EQ(1U, Thread::Current()->NumStackReferences()); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 286 | return x - y; // non-commutative operator |
| 287 | } |
| 288 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 289 | void JniCompilerTest::CompileAndRunIntIntMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 290 | SetUpForTest(false, "fooII", "(II)I", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 291 | reinterpret_cast<void*>(&Java_MyClassNatives_fooII)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 292 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 293 | EXPECT_EQ(0, gJava_MyClassNatives_fooII_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 294 | jint result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 99, 10); |
| 295 | EXPECT_EQ(99 - 10, result); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 296 | EXPECT_EQ(1, gJava_MyClassNatives_fooII_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 297 | result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 0xCAFEBABE, |
| 298 | 0xCAFED00D); |
| 299 | EXPECT_EQ(static_cast<jint>(0xCAFEBABE - 0xCAFED00D), result); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 300 | EXPECT_EQ(2, gJava_MyClassNatives_fooII_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 301 | |
| 302 | gJava_MyClassNatives_fooII_calls = 0; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 303 | } |
| 304 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 305 | JNI_TEST(CompileAndRunIntIntMethod) |
| 306 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 307 | int gJava_MyClassNatives_fooJJ_calls = 0; |
| 308 | jlong Java_MyClassNatives_fooJJ(JNIEnv* env, jobject thisObj, jlong x, jlong y) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 309 | // 1 = thisObj |
Ian Rogers | 50b35e2 | 2012-10-04 10:09:15 -0700 | [diff] [blame] | 310 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
Ian Rogers | 9b269d2 | 2011-09-04 14:06:05 -0700 | [diff] [blame] | 311 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 312 | EXPECT_TRUE(thisObj != nullptr); |
Ian Rogers | 9b269d2 | 2011-09-04 14:06:05 -0700 | [diff] [blame] | 313 | EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 314 | gJava_MyClassNatives_fooJJ_calls++; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 315 | ScopedObjectAccess soa(Thread::Current()); |
| 316 | EXPECT_EQ(1U, Thread::Current()->NumStackReferences()); |
Ian Rogers | 9b269d2 | 2011-09-04 14:06:05 -0700 | [diff] [blame] | 317 | return x - y; // non-commutative operator |
| 318 | } |
| 319 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 320 | void JniCompilerTest::CompileAndRunLongLongMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 321 | SetUpForTest(false, "fooJJ", "(JJ)J", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 322 | reinterpret_cast<void*>(&Java_MyClassNatives_fooJJ)); |
Ian Rogers | 9b269d2 | 2011-09-04 14:06:05 -0700 | [diff] [blame] | 323 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 324 | EXPECT_EQ(0, gJava_MyClassNatives_fooJJ_calls); |
Ian Rogers | 0f67847 | 2014-03-10 16:18:37 -0700 | [diff] [blame] | 325 | jlong a = INT64_C(0x1234567890ABCDEF); |
| 326 | jlong b = INT64_C(0xFEDCBA0987654321); |
Ian Rogers | 9b269d2 | 2011-09-04 14:06:05 -0700 | [diff] [blame] | 327 | jlong result = env_->CallNonvirtualLongMethod(jobj_, jklass_, jmethod_, a, b); |
| 328 | EXPECT_EQ(a - b, result); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 329 | EXPECT_EQ(1, gJava_MyClassNatives_fooJJ_calls); |
Ian Rogers | 9b269d2 | 2011-09-04 14:06:05 -0700 | [diff] [blame] | 330 | result = env_->CallNonvirtualLongMethod(jobj_, jklass_, jmethod_, b, a); |
| 331 | EXPECT_EQ(b - a, result); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 332 | EXPECT_EQ(2, gJava_MyClassNatives_fooJJ_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 333 | |
| 334 | gJava_MyClassNatives_fooJJ_calls = 0; |
Ian Rogers | 9b269d2 | 2011-09-04 14:06:05 -0700 | [diff] [blame] | 335 | } |
| 336 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 337 | JNI_TEST(CompileAndRunLongLongMethod) |
| 338 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 339 | int gJava_MyClassNatives_fooDD_calls = 0; |
| 340 | jdouble Java_MyClassNatives_fooDD(JNIEnv* env, jobject thisObj, jdouble x, jdouble y) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 341 | // 1 = thisObj |
Ian Rogers | 50b35e2 | 2012-10-04 10:09:15 -0700 | [diff] [blame] | 342 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 343 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 344 | EXPECT_TRUE(thisObj != nullptr); |
Ian Rogers | a8cd9f4 | 2011-08-19 16:43:41 -0700 | [diff] [blame] | 345 | EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 346 | gJava_MyClassNatives_fooDD_calls++; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 347 | ScopedObjectAccess soa(Thread::Current()); |
| 348 | EXPECT_EQ(1U, Thread::Current()->NumStackReferences()); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 349 | return x - y; // non-commutative operator |
| 350 | } |
| 351 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 352 | void JniCompilerTest::CompileAndRunDoubleDoubleMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 353 | SetUpForTest(false, "fooDD", "(DD)D", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 354 | reinterpret_cast<void*>(&Java_MyClassNatives_fooDD)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 355 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 356 | EXPECT_EQ(0, gJava_MyClassNatives_fooDD_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 357 | jdouble result = env_->CallNonvirtualDoubleMethod(jobj_, jklass_, jmethod_, |
| 358 | 99.0, 10.0); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 359 | EXPECT_DOUBLE_EQ(99.0 - 10.0, result); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 360 | EXPECT_EQ(1, gJava_MyClassNatives_fooDD_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 361 | jdouble a = 3.14159265358979323846; |
| 362 | jdouble b = 0.69314718055994530942; |
| 363 | result = env_->CallNonvirtualDoubleMethod(jobj_, jklass_, jmethod_, a, b); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 364 | EXPECT_DOUBLE_EQ(a - b, result); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 365 | EXPECT_EQ(2, gJava_MyClassNatives_fooDD_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 366 | |
| 367 | gJava_MyClassNatives_fooDD_calls = 0; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Elliott Hughes | 3e778f7 | 2012-05-21 15:29:52 -0700 | [diff] [blame] | 370 | int gJava_MyClassNatives_fooJJ_synchronized_calls = 0; |
| 371 | jlong Java_MyClassNatives_fooJJ_synchronized(JNIEnv* env, jobject thisObj, jlong x, jlong y) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 372 | // 1 = thisObj |
Ian Rogers | 50b35e2 | 2012-10-04 10:09:15 -0700 | [diff] [blame] | 373 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
Elliott Hughes | 3e778f7 | 2012-05-21 15:29:52 -0700 | [diff] [blame] | 374 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 375 | EXPECT_TRUE(thisObj != nullptr); |
Elliott Hughes | 3e778f7 | 2012-05-21 15:29:52 -0700 | [diff] [blame] | 376 | EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_)); |
| 377 | gJava_MyClassNatives_fooJJ_synchronized_calls++; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 378 | ScopedObjectAccess soa(Thread::Current()); |
| 379 | EXPECT_EQ(1U, Thread::Current()->NumStackReferences()); |
Elliott Hughes | 3e778f7 | 2012-05-21 15:29:52 -0700 | [diff] [blame] | 380 | return x | y; |
| 381 | } |
| 382 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 383 | void JniCompilerTest::CompileAndRun_fooJJ_synchronizedImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 384 | SetUpForTest(false, "fooJJ_synchronized", "(JJ)J", |
Elliott Hughes | 3e778f7 | 2012-05-21 15:29:52 -0700 | [diff] [blame] | 385 | reinterpret_cast<void*>(&Java_MyClassNatives_fooJJ_synchronized)); |
| 386 | |
| 387 | EXPECT_EQ(0, gJava_MyClassNatives_fooJJ_synchronized_calls); |
| 388 | jlong a = 0x1000000020000000ULL; |
| 389 | jlong b = 0x00ff000000aa0000ULL; |
| 390 | jlong result = env_->CallNonvirtualLongMethod(jobj_, jklass_, jmethod_, a, b); |
| 391 | EXPECT_EQ(a | b, result); |
| 392 | EXPECT_EQ(1, gJava_MyClassNatives_fooJJ_synchronized_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 393 | |
| 394 | gJava_MyClassNatives_fooJJ_synchronized_calls = 0; |
Elliott Hughes | 3e778f7 | 2012-05-21 15:29:52 -0700 | [diff] [blame] | 395 | } |
| 396 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 397 | JNI_TEST(CompileAndRun_fooJJ_synchronized) |
| 398 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 399 | int gJava_MyClassNatives_fooIOO_calls = 0; |
| 400 | jobject Java_MyClassNatives_fooIOO(JNIEnv* env, jobject thisObj, jint x, jobject y, |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 401 | jobject z) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 402 | // 3 = this + y + z |
Ian Rogers | 50b35e2 | 2012-10-04 10:09:15 -0700 | [diff] [blame] | 403 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 404 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 405 | EXPECT_TRUE(thisObj != nullptr); |
Ian Rogers | a8cd9f4 | 2011-08-19 16:43:41 -0700 | [diff] [blame] | 406 | EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 407 | gJava_MyClassNatives_fooIOO_calls++; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 408 | ScopedObjectAccess soa(Thread::Current()); |
Andreas Gampe | bf6b92a | 2014-03-05 16:11:04 -0800 | [diff] [blame] | 409 | size_t null_args = (y == nullptr ? 1 : 0) + (z == nullptr ? 1 : 0); |
| 410 | EXPECT_TRUE(3U == Thread::Current()->NumStackReferences() || |
| 411 | (3U - null_args) == Thread::Current()->NumStackReferences()); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 412 | switch (x) { |
| 413 | case 1: |
| 414 | return y; |
| 415 | case 2: |
| 416 | return z; |
| 417 | default: |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 418 | return thisObj; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 419 | } |
| 420 | } |
| 421 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 422 | void JniCompilerTest::CompileAndRunIntObjectObjectMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 423 | SetUpForTest(false, "fooIOO", |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 424 | "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 425 | reinterpret_cast<void*>(&Java_MyClassNatives_fooIOO)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 426 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 427 | EXPECT_EQ(0, gJava_MyClassNatives_fooIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 428 | jobject result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 0, nullptr, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 429 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 430 | EXPECT_EQ(1, gJava_MyClassNatives_fooIOO_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 431 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 432 | result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 0, nullptr, jklass_); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 433 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 434 | EXPECT_EQ(2, gJava_MyClassNatives_fooIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 435 | result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 1, nullptr, jklass_); |
| 436 | EXPECT_TRUE(env_->IsSameObject(nullptr, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 437 | EXPECT_EQ(3, gJava_MyClassNatives_fooIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 438 | result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 2, nullptr, jklass_); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 439 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 440 | EXPECT_EQ(4, gJava_MyClassNatives_fooIOO_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 441 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 442 | result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 0, jklass_, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 443 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 444 | EXPECT_EQ(5, gJava_MyClassNatives_fooIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 445 | result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 1, jklass_, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 446 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 447 | EXPECT_EQ(6, gJava_MyClassNatives_fooIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 448 | result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 2, jklass_, nullptr); |
| 449 | EXPECT_TRUE(env_->IsSameObject(nullptr, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 450 | EXPECT_EQ(7, gJava_MyClassNatives_fooIOO_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 451 | |
| 452 | gJava_MyClassNatives_fooIOO_calls = 0; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 453 | } |
| 454 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 455 | JNI_TEST(CompileAndRunIntObjectObjectMethod) |
| 456 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 457 | int gJava_MyClassNatives_fooSII_calls = 0; |
| 458 | jint Java_MyClassNatives_fooSII(JNIEnv* env, jclass klass, jint x, jint y) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 459 | // 1 = klass |
Ian Rogers | 50b35e2 | 2012-10-04 10:09:15 -0700 | [diff] [blame] | 460 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
Shih-wei Liao | 82da44b | 2011-09-01 00:38:04 -0700 | [diff] [blame] | 461 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 462 | EXPECT_TRUE(klass != nullptr); |
Shih-wei Liao | 82da44b | 2011-09-01 00:38:04 -0700 | [diff] [blame] | 463 | EXPECT_TRUE(env->IsInstanceOf(JniCompilerTest::jobj_, klass)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 464 | gJava_MyClassNatives_fooSII_calls++; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 465 | ScopedObjectAccess soa(Thread::Current()); |
| 466 | EXPECT_EQ(1U, Thread::Current()->NumStackReferences()); |
Shih-wei Liao | 82da44b | 2011-09-01 00:38:04 -0700 | [diff] [blame] | 467 | return x + y; |
| 468 | } |
| 469 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 470 | void JniCompilerTest::CompileAndRunStaticIntIntMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 471 | SetUpForTest(true, "fooSII", "(II)I", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 472 | reinterpret_cast<void*>(&Java_MyClassNatives_fooSII)); |
Shih-wei Liao | 82da44b | 2011-09-01 00:38:04 -0700 | [diff] [blame] | 473 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 474 | EXPECT_EQ(0, gJava_MyClassNatives_fooSII_calls); |
Shih-wei Liao | 82da44b | 2011-09-01 00:38:04 -0700 | [diff] [blame] | 475 | jint result = env_->CallStaticIntMethod(jklass_, jmethod_, 20, 30); |
| 476 | EXPECT_EQ(50, result); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 477 | EXPECT_EQ(1, gJava_MyClassNatives_fooSII_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 478 | |
| 479 | gJava_MyClassNatives_fooSII_calls = 0; |
Shih-wei Liao | 82da44b | 2011-09-01 00:38:04 -0700 | [diff] [blame] | 480 | } |
| 481 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 482 | JNI_TEST(CompileAndRunStaticIntIntMethod) |
| 483 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 484 | int gJava_MyClassNatives_fooSDD_calls = 0; |
| 485 | jdouble Java_MyClassNatives_fooSDD(JNIEnv* env, jclass klass, jdouble x, jdouble y) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 486 | // 1 = klass |
Ian Rogers | 50b35e2 | 2012-10-04 10:09:15 -0700 | [diff] [blame] | 487 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 488 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 489 | EXPECT_TRUE(klass != nullptr); |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 490 | EXPECT_TRUE(env->IsInstanceOf(JniCompilerTest::jobj_, klass)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 491 | gJava_MyClassNatives_fooSDD_calls++; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 492 | ScopedObjectAccess soa(Thread::Current()); |
| 493 | EXPECT_EQ(1U, Thread::Current()->NumStackReferences()); |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 494 | return x - y; // non-commutative operator |
| 495 | } |
| 496 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 497 | void JniCompilerTest::CompileAndRunStaticDoubleDoubleMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 498 | SetUpForTest(true, "fooSDD", "(DD)D", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 499 | reinterpret_cast<void*>(&Java_MyClassNatives_fooSDD)); |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 500 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 501 | EXPECT_EQ(0, gJava_MyClassNatives_fooSDD_calls); |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 502 | jdouble result = env_->CallStaticDoubleMethod(jklass_, jmethod_, 99.0, 10.0); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 503 | EXPECT_DOUBLE_EQ(99.0 - 10.0, result); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 504 | EXPECT_EQ(1, gJava_MyClassNatives_fooSDD_calls); |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 505 | jdouble a = 3.14159265358979323846; |
| 506 | jdouble b = 0.69314718055994530942; |
| 507 | result = env_->CallStaticDoubleMethod(jklass_, jmethod_, a, b); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 508 | EXPECT_DOUBLE_EQ(a - b, result); |
| 509 | EXPECT_DOUBLE_EQ(2, gJava_MyClassNatives_fooSDD_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 510 | |
| 511 | gJava_MyClassNatives_fooSDD_calls = 0; |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 512 | } |
| 513 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 514 | JNI_TEST(CompileAndRunStaticDoubleDoubleMethod) |
| 515 | |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 516 | // The x86 generic JNI code had a bug where it assumed a floating |
| 517 | // point return value would be in xmm0. We use log, to somehow ensure |
| 518 | // the compiler will use the floating point stack. |
| 519 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 520 | jdouble Java_MyClassNatives_logD(JNIEnv*, jclass, jdouble x) { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 521 | return log(x); |
| 522 | } |
| 523 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 524 | void JniCompilerTest::RunStaticLogDoubleMethodImpl() { |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 525 | SetUpForTest(true, "logD", "(D)D", reinterpret_cast<void*>(&Java_MyClassNatives_logD)); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 526 | |
| 527 | jdouble result = env_->CallStaticDoubleMethod(jklass_, jmethod_, 2.0); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 528 | EXPECT_DOUBLE_EQ(log(2.0), result); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 529 | } |
| 530 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 531 | JNI_TEST(RunStaticLogDoubleMethod) |
| 532 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 533 | jfloat Java_MyClassNatives_logF(JNIEnv*, jclass, jfloat x) { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 534 | return logf(x); |
| 535 | } |
| 536 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 537 | void JniCompilerTest::RunStaticLogFloatMethodImpl() { |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 538 | SetUpForTest(true, "logF", "(F)F", reinterpret_cast<void*>(&Java_MyClassNatives_logF)); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 539 | |
| 540 | jfloat result = env_->CallStaticFloatMethod(jklass_, jmethod_, 2.0); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 541 | EXPECT_FLOAT_EQ(logf(2.0), result); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 542 | } |
| 543 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 544 | JNI_TEST(RunStaticLogFloatMethod) |
| 545 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 546 | jboolean Java_MyClassNatives_returnTrue(JNIEnv*, jclass) { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 547 | return JNI_TRUE; |
| 548 | } |
| 549 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 550 | jboolean Java_MyClassNatives_returnFalse(JNIEnv*, jclass) { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 551 | return JNI_FALSE; |
| 552 | } |
| 553 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 554 | jint Java_MyClassNatives_returnInt(JNIEnv*, jclass) { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 555 | return 42; |
| 556 | } |
| 557 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 558 | void JniCompilerTest::RunStaticReturnTrueImpl() { |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 559 | SetUpForTest(true, "returnTrue", "()Z", reinterpret_cast<void*>(&Java_MyClassNatives_returnTrue)); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 560 | |
| 561 | jboolean result = env_->CallStaticBooleanMethod(jklass_, jmethod_); |
| 562 | EXPECT_TRUE(result); |
| 563 | } |
| 564 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 565 | JNI_TEST(RunStaticReturnTrue) |
| 566 | |
| 567 | void JniCompilerTest::RunStaticReturnFalseImpl() { |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 568 | SetUpForTest(true, "returnFalse", "()Z", |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 569 | reinterpret_cast<void*>(&Java_MyClassNatives_returnFalse)); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 570 | |
| 571 | jboolean result = env_->CallStaticBooleanMethod(jklass_, jmethod_); |
| 572 | EXPECT_FALSE(result); |
| 573 | } |
| 574 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 575 | JNI_TEST(RunStaticReturnFalse) |
| 576 | |
| 577 | void JniCompilerTest::RunGenericStaticReturnIntImpl() { |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 578 | SetUpForTest(true, "returnInt", "()I", reinterpret_cast<void*>(&Java_MyClassNatives_returnInt)); |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 579 | |
| 580 | jint result = env_->CallStaticIntMethod(jklass_, jmethod_); |
| 581 | EXPECT_EQ(42, result); |
| 582 | } |
| 583 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 584 | JNI_TEST(RunGenericStaticReturnInt) |
| 585 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 586 | int gJava_MyClassNatives_fooSIOO_calls = 0; |
| 587 | jobject Java_MyClassNatives_fooSIOO(JNIEnv* env, jclass klass, jint x, jobject y, |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 588 | jobject z) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 589 | // 3 = klass + y + z |
Ian Rogers | 50b35e2 | 2012-10-04 10:09:15 -0700 | [diff] [blame] | 590 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 591 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 592 | EXPECT_TRUE(klass != nullptr); |
Ian Rogers | a8cd9f4 | 2011-08-19 16:43:41 -0700 | [diff] [blame] | 593 | EXPECT_TRUE(env->IsInstanceOf(JniCompilerTest::jobj_, klass)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 594 | gJava_MyClassNatives_fooSIOO_calls++; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 595 | ScopedObjectAccess soa(Thread::Current()); |
Andreas Gampe | bf6b92a | 2014-03-05 16:11:04 -0800 | [diff] [blame] | 596 | size_t null_args = (y == nullptr ? 1 : 0) + (z == nullptr ? 1 : 0); |
| 597 | EXPECT_TRUE(3U == Thread::Current()->NumStackReferences() || |
| 598 | (3U - null_args) == Thread::Current()->NumStackReferences()); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 599 | switch (x) { |
| 600 | case 1: |
| 601 | return y; |
| 602 | case 2: |
| 603 | return z; |
| 604 | default: |
| 605 | return klass; |
| 606 | } |
| 607 | } |
| 608 | |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 609 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 610 | void JniCompilerTest::CompileAndRunStaticIntObjectObjectMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 611 | SetUpForTest(true, "fooSIOO", |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 612 | "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 613 | reinterpret_cast<void*>(&Java_MyClassNatives_fooSIOO)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 614 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 615 | EXPECT_EQ(0, gJava_MyClassNatives_fooSIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 616 | jobject result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, nullptr, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 617 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 618 | EXPECT_EQ(1, gJava_MyClassNatives_fooSIOO_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 619 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 620 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, nullptr, jobj_); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 621 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 622 | EXPECT_EQ(2, gJava_MyClassNatives_fooSIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 623 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, nullptr, jobj_); |
| 624 | EXPECT_TRUE(env_->IsSameObject(nullptr, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 625 | EXPECT_EQ(3, gJava_MyClassNatives_fooSIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 626 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 2, nullptr, jobj_); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 627 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 628 | EXPECT_EQ(4, gJava_MyClassNatives_fooSIOO_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 629 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 630 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, jobj_, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 631 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 632 | EXPECT_EQ(5, gJava_MyClassNatives_fooSIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 633 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, jobj_, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 634 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 635 | EXPECT_EQ(6, gJava_MyClassNatives_fooSIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 636 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 2, jobj_, nullptr); |
| 637 | EXPECT_TRUE(env_->IsSameObject(nullptr, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 638 | EXPECT_EQ(7, gJava_MyClassNatives_fooSIOO_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 639 | |
| 640 | gJava_MyClassNatives_fooSIOO_calls = 0; |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 641 | } |
| 642 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 643 | JNI_TEST(CompileAndRunStaticIntObjectObjectMethod) |
| 644 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 645 | int gJava_MyClassNatives_fooSSIOO_calls = 0; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 646 | jobject Java_MyClassNatives_fooSSIOO(JNIEnv* env, jclass klass, jint x, jobject y, jobject z) { |
| 647 | // 3 = klass + y + z |
Ian Rogers | 50b35e2 | 2012-10-04 10:09:15 -0700 | [diff] [blame] | 648 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 649 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 650 | EXPECT_TRUE(klass != nullptr); |
Ian Rogers | a8cd9f4 | 2011-08-19 16:43:41 -0700 | [diff] [blame] | 651 | EXPECT_TRUE(env->IsInstanceOf(JniCompilerTest::jobj_, klass)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 652 | gJava_MyClassNatives_fooSSIOO_calls++; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 653 | ScopedObjectAccess soa(Thread::Current()); |
Andreas Gampe | bf6b92a | 2014-03-05 16:11:04 -0800 | [diff] [blame] | 654 | size_t null_args = (y == nullptr ? 1 : 0) + (z == nullptr ? 1 : 0); |
| 655 | EXPECT_TRUE(3U == Thread::Current()->NumStackReferences() || |
| 656 | (3U - null_args) == Thread::Current()->NumStackReferences()); |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 657 | switch (x) { |
| 658 | case 1: |
| 659 | return y; |
| 660 | case 2: |
| 661 | return z; |
| 662 | default: |
| 663 | return klass; |
| 664 | } |
| 665 | } |
| 666 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 667 | void JniCompilerTest::CompileAndRunStaticSynchronizedIntObjectObjectMethodImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 668 | SetUpForTest(true, "fooSSIOO", |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 669 | "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 670 | reinterpret_cast<void*>(&Java_MyClassNatives_fooSSIOO)); |
Carl Shapiro | 419ec7b | 2011-08-03 14:48:33 -0700 | [diff] [blame] | 671 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 672 | EXPECT_EQ(0, gJava_MyClassNatives_fooSSIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 673 | jobject result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, nullptr, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 674 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 675 | EXPECT_EQ(1, gJava_MyClassNatives_fooSSIOO_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 676 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 677 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, nullptr, jobj_); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 678 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 679 | EXPECT_EQ(2, gJava_MyClassNatives_fooSSIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 680 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, nullptr, jobj_); |
| 681 | EXPECT_TRUE(env_->IsSameObject(nullptr, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 682 | EXPECT_EQ(3, gJava_MyClassNatives_fooSSIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 683 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 2, nullptr, jobj_); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 684 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 685 | EXPECT_EQ(4, gJava_MyClassNatives_fooSSIOO_calls); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 686 | |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 687 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, jobj_, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 688 | EXPECT_TRUE(env_->IsSameObject(jklass_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 689 | EXPECT_EQ(5, gJava_MyClassNatives_fooSSIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 690 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, jobj_, nullptr); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 691 | EXPECT_TRUE(env_->IsSameObject(jobj_, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 692 | EXPECT_EQ(6, gJava_MyClassNatives_fooSSIOO_calls); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 693 | result = env_->CallStaticObjectMethod(jklass_, jmethod_, 2, jobj_, nullptr); |
| 694 | EXPECT_TRUE(env_->IsSameObject(nullptr, result)); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 695 | EXPECT_EQ(7, gJava_MyClassNatives_fooSSIOO_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 696 | |
| 697 | gJava_MyClassNatives_fooSSIOO_calls = 0; |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 698 | } |
| 699 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 700 | JNI_TEST(CompileAndRunStaticSynchronizedIntObjectObjectMethod) |
| 701 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 702 | void Java_MyClassNatives_throwException(JNIEnv* env, jobject) { |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 703 | jclass c = env->FindClass("java/lang/RuntimeException"); |
| 704 | env->ThrowNew(c, "hello"); |
| 705 | } |
Ian Rogers | 45a76cb | 2011-07-21 22:00:15 -0700 | [diff] [blame] | 706 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 707 | void JniCompilerTest::ExceptionHandlingImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 708 | { |
| 709 | ASSERT_FALSE(runtime_->IsStarted()); |
| 710 | ScopedObjectAccess soa(Thread::Current()); |
| 711 | class_loader_ = LoadDex("MyClassNatives"); |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 712 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 713 | // all compilation needs to happen before Runtime::Start |
| 714 | CompileForTest(class_loader_, false, "foo", "()V"); |
| 715 | CompileForTest(class_loader_, false, "throwException", "()V"); |
| 716 | CompileForTest(class_loader_, false, "foo", "()V"); |
| 717 | } |
| 718 | // Start runtime to avoid re-initialization in SetupForTest. |
| 719 | Thread::Current()->TransitionFromSuspendedToRunnable(); |
Brian Carlstrom | bd86bcc | 2013-03-10 20:26:16 -0700 | [diff] [blame] | 720 | bool started = runtime_->Start(); |
| 721 | CHECK(started); |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 722 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 723 | gJava_MyClassNatives_foo_calls = 0; |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 724 | |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 725 | // Check a single call of a JNI method is ok |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 726 | SetUpForTest(false, "foo", "()V", reinterpret_cast<void*>(&Java_MyClassNatives_foo)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 727 | env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 728 | EXPECT_EQ(1, gJava_MyClassNatives_foo_calls); |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 729 | EXPECT_FALSE(Thread::Current()->IsExceptionPending()); |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 730 | |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 731 | // Get class for exception we expect to be thrown |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 732 | ScopedLocalRef<jclass> jlre(env_, env_->FindClass("java/lang/RuntimeException")); |
| 733 | SetUpForTest(false, "throwException", "()V", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 734 | reinterpret_cast<void*>(&Java_MyClassNatives_throwException)); |
| 735 | // Call Java_MyClassNatives_throwException (JNI method that throws exception) |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 736 | env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 737 | EXPECT_EQ(1, gJava_MyClassNatives_foo_calls); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 738 | EXPECT_TRUE(env_->ExceptionCheck() == JNI_TRUE); |
| 739 | ScopedLocalRef<jthrowable> exception(env_, env_->ExceptionOccurred()); |
| 740 | env_->ExceptionClear(); |
| 741 | EXPECT_TRUE(env_->IsInstanceOf(exception.get(), jlre.get())); |
Elliott Hughes | a250199 | 2011-08-26 19:39:54 -0700 | [diff] [blame] | 742 | |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 743 | // Check a single call of a JNI method is ok |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 744 | SetUpForTest(false, "foo", "()V", reinterpret_cast<void*>(&Java_MyClassNatives_foo)); |
Ian Rogers | cdd1d2d | 2011-08-18 09:58:17 -0700 | [diff] [blame] | 745 | env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 746 | EXPECT_EQ(2, gJava_MyClassNatives_foo_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 747 | |
| 748 | gJava_MyClassNatives_foo_calls = 0; |
Ian Rogers | 45a76cb | 2011-07-21 22:00:15 -0700 | [diff] [blame] | 749 | } |
| 750 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 751 | JNI_TEST(ExceptionHandling) |
| 752 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 753 | jint Java_MyClassNatives_nativeUpCall(JNIEnv* env, jobject thisObj, jint i) { |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 754 | if (i <= 0) { |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 755 | // We want to check raw Object* / Array* below |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 756 | ScopedObjectAccess soa(env); |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 757 | |
| 758 | // Build stack trace |
Sebastien Hertz | ee1d79a | 2014-02-21 15:46:30 +0100 | [diff] [blame] | 759 | jobject internal = Thread::Current()->CreateInternalStackTrace<false>(soa); |
Ian Rogers | 53b8b09 | 2014-03-13 23:45:53 -0700 | [diff] [blame] | 760 | jobjectArray ste_array = Thread::InternalStackTraceToStackTraceElementArray(soa, internal); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 761 | mirror::ObjectArray<mirror::StackTraceElement>* trace_array = |
| 762 | soa.Decode<mirror::ObjectArray<mirror::StackTraceElement>*>(ste_array); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 763 | EXPECT_TRUE(trace_array != nullptr); |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 764 | EXPECT_EQ(11, trace_array->GetLength()); |
| 765 | |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 766 | // Check stack trace entries have expected values |
Andreas Gampe | 277ccbd | 2014-11-03 21:36:10 -0800 | [diff] [blame] | 767 | for (int32_t j = 0; j < trace_array->GetLength(); ++j) { |
| 768 | EXPECT_EQ(-2, trace_array->Get(j)->GetLineNumber()); |
| 769 | mirror::StackTraceElement* ste = trace_array->Get(j); |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 770 | EXPECT_STREQ("MyClassNatives.java", ste->GetFileName()->ToModifiedUtf8().c_str()); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 771 | EXPECT_STREQ("MyClassNatives", ste->GetDeclaringClass()->ToModifiedUtf8().c_str()); |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 772 | EXPECT_STREQ("fooI", ste->GetMethodName()->ToModifiedUtf8().c_str()); |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 773 | } |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 774 | |
| 775 | // end recursion |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 776 | return 0; |
| 777 | } else { |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 778 | jclass jklass = env->FindClass("MyClassNatives"); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 779 | EXPECT_TRUE(jklass != nullptr); |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 780 | jmethodID jmethod = env->GetMethodID(jklass, "fooI", "(I)I"); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 781 | EXPECT_TRUE(jmethod != nullptr); |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 782 | |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 783 | // Recurse with i - 1 |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 784 | jint result = env->CallNonvirtualIntMethod(thisObj, jklass, jmethod, i - 1); |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 785 | |
| 786 | // Return sum of all depths |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 787 | return i + result; |
| 788 | } |
| 789 | } |
| 790 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 791 | void JniCompilerTest::NativeStackTraceElementImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 792 | SetUpForTest(false, "fooI", "(I)I", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 793 | reinterpret_cast<void*>(&Java_MyClassNatives_nativeUpCall)); |
Shih-wei Liao | ff0f9be | 2011-08-29 15:43:53 -0700 | [diff] [blame] | 794 | jint result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 10); |
Ian Rogers | aaa2080 | 2011-09-11 21:47:37 -0700 | [diff] [blame] | 795 | 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] | 796 | } |
| 797 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 798 | JNI_TEST(NativeStackTraceElement) |
| 799 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 800 | jobject Java_MyClassNatives_fooO(JNIEnv* env, jobject, jobject x) { |
Shih-wei Liao | 558788e | 2011-09-01 02:39:11 -0700 | [diff] [blame] | 801 | return env->NewGlobalRef(x); |
| 802 | } |
| 803 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 804 | void JniCompilerTest::ReturnGlobalRefImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 805 | SetUpForTest(false, "fooO", "(Ljava/lang/Object;)Ljava/lang/Object;", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 806 | reinterpret_cast<void*>(&Java_MyClassNatives_fooO)); |
Shih-wei Liao | 558788e | 2011-09-01 02:39:11 -0700 | [diff] [blame] | 807 | jobject result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, jobj_); |
| 808 | EXPECT_EQ(JNILocalRefType, env_->GetObjectRefType(result)); |
| 809 | EXPECT_TRUE(env_->IsSameObject(result, jobj_)); |
| 810 | } |
| 811 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 812 | JNI_TEST(ReturnGlobalRef) |
| 813 | |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 814 | jint local_ref_test(JNIEnv* env, jobject thisObj, jint x) { |
| 815 | // Add 10 local references |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 816 | ScopedObjectAccess soa(env); |
Ian Rogers | 5a7a74a | 2011-09-26 16:32:29 -0700 | [diff] [blame] | 817 | for (int i = 0; i < 10; i++) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 818 | soa.AddLocalReference<jobject>(soa.Decode<mirror::Object*>(thisObj)); |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 819 | } |
| 820 | return x+1; |
| 821 | } |
| 822 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 823 | void JniCompilerTest::LocalReferenceTableClearingTestImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 824 | SetUpForTest(false, "fooI", "(I)I", reinterpret_cast<void*>(&local_ref_test)); |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 825 | // 1000 invocations of a method that adds 10 local references |
Elliott Hughes | b25c3f6 | 2012-03-26 16:35:06 -0700 | [diff] [blame] | 826 | for (int i = 0; i < 1000; i++) { |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 827 | jint result = env_->CallIntMethod(jobj_, jmethod_, i); |
| 828 | EXPECT_TRUE(result == i + 1); |
| 829 | } |
| 830 | } |
| 831 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 832 | JNI_TEST(LocalReferenceTableClearingTest) |
| 833 | |
Ian Rogers | b9231c8 | 2011-09-05 22:13:19 -0700 | [diff] [blame] | 834 | void my_arraycopy(JNIEnv* env, jclass klass, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length) { |
| 835 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jklass_, klass)); |
| 836 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jklass_, dst)); |
Ian Rogers | 82f3e09 | 2011-09-05 22:54:45 -0700 | [diff] [blame] | 837 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jobj_, src)); |
Ian Rogers | b9231c8 | 2011-09-05 22:13:19 -0700 | [diff] [blame] | 838 | EXPECT_EQ(1234, src_pos); |
| 839 | EXPECT_EQ(5678, dst_pos); |
| 840 | EXPECT_EQ(9876, length); |
| 841 | } |
| 842 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 843 | void JniCompilerTest::JavaLangSystemArrayCopyImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 844 | SetUpForTest(true, "arraycopy", "(Ljava/lang/Object;ILjava/lang/Object;II)V", |
Ian Rogers | b9231c8 | 2011-09-05 22:13:19 -0700 | [diff] [blame] | 845 | reinterpret_cast<void*>(&my_arraycopy)); |
Ian Rogers | 82f3e09 | 2011-09-05 22:54:45 -0700 | [diff] [blame] | 846 | env_->CallStaticVoidMethod(jklass_, jmethod_, jobj_, 1234, jklass_, 5678, 9876); |
Ian Rogers | b9231c8 | 2011-09-05 22:13:19 -0700 | [diff] [blame] | 847 | } |
| 848 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 849 | JNI_TEST(JavaLangSystemArrayCopy) |
| 850 | |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 851 | jboolean my_casi(JNIEnv* env, jobject unsafe, jobject obj, jlong offset, jint expected, jint newval) { |
| 852 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jobj_, unsafe)); |
| 853 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jobj_, obj)); |
Ian Rogers | 0f67847 | 2014-03-10 16:18:37 -0700 | [diff] [blame] | 854 | EXPECT_EQ(INT64_C(0x12345678ABCDEF88), offset); |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 855 | EXPECT_EQ(static_cast<jint>(0xCAFEF00D), expected); |
| 856 | EXPECT_EQ(static_cast<jint>(0xEBADF00D), newval); |
| 857 | return JNI_TRUE; |
| 858 | } |
| 859 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 860 | void JniCompilerTest::CompareAndSwapIntImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 861 | SetUpForTest(false, "compareAndSwapInt", "(Ljava/lang/Object;JII)Z", |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 862 | reinterpret_cast<void*>(&my_casi)); |
Ian Rogers | 0f67847 | 2014-03-10 16:18:37 -0700 | [diff] [blame] | 863 | jboolean result = env_->CallBooleanMethod(jobj_, jmethod_, jobj_, INT64_C(0x12345678ABCDEF88), |
| 864 | 0xCAFEF00D, 0xEBADF00D); |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 865 | EXPECT_EQ(result, JNI_TRUE); |
| 866 | } |
| 867 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 868 | JNI_TEST(CompareAndSwapInt) |
| 869 | |
Ian Rogers | c779284 | 2012-03-03 15:36:20 -0800 | [diff] [blame] | 870 | jint my_gettext(JNIEnv* env, jclass klass, jlong val1, jobject obj1, jlong val2, jobject obj2) { |
| 871 | EXPECT_TRUE(env->IsInstanceOf(JniCompilerTest::jobj_, klass)); |
| 872 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jobj_, obj1)); |
| 873 | EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jobj_, obj2)); |
| 874 | EXPECT_EQ(0x12345678ABCDEF88ll, val1); |
| 875 | EXPECT_EQ(0x7FEDCBA987654321ll, val2); |
| 876 | return 42; |
| 877 | } |
| 878 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 879 | void JniCompilerTest::GetTextImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 880 | SetUpForTest(true, "getText", "(JLjava/lang/Object;JLjava/lang/Object;)I", |
Ian Rogers | c779284 | 2012-03-03 15:36:20 -0800 | [diff] [blame] | 881 | reinterpret_cast<void*>(&my_gettext)); |
| 882 | jint result = env_->CallStaticIntMethod(jklass_, jmethod_, 0x12345678ABCDEF88ll, jobj_, |
Ian Rogers | 0f67847 | 2014-03-10 16:18:37 -0700 | [diff] [blame] | 883 | INT64_C(0x7FEDCBA987654321), jobj_); |
Ian Rogers | c779284 | 2012-03-03 15:36:20 -0800 | [diff] [blame] | 884 | EXPECT_EQ(result, 42); |
| 885 | } |
| 886 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 887 | JNI_TEST(GetText) |
| 888 | |
Vladimir Marko | 4e24b9d | 2014-07-24 17:01:58 +0100 | [diff] [blame] | 889 | int gJava_MyClassNatives_GetSinkProperties_calls = 0; |
| 890 | jarray Java_MyClassNatives_GetSinkProperties(JNIEnv* env, jobject thisObj, jstring s) { |
| 891 | // 1 = thisObj |
| 892 | Thread* self = Thread::Current(); |
| 893 | EXPECT_EQ(kNative, self->GetState()); |
| 894 | Locks::mutator_lock_->AssertNotHeld(self); |
| 895 | EXPECT_EQ(self->GetJniEnv(), env); |
| 896 | EXPECT_TRUE(thisObj != nullptr); |
| 897 | EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_)); |
| 898 | EXPECT_EQ(s, nullptr); |
| 899 | gJava_MyClassNatives_GetSinkProperties_calls++; |
| 900 | ScopedObjectAccess soa(self); |
| 901 | EXPECT_EQ(2U, self->NumStackReferences()); |
| 902 | EXPECT_TRUE(self->HoldsLock(soa.Decode<mirror::Object*>(thisObj))); |
| 903 | return nullptr; |
| 904 | } |
| 905 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 906 | void JniCompilerTest::GetSinkPropertiesNativeImpl() { |
Vladimir Marko | 4e24b9d | 2014-07-24 17:01:58 +0100 | [diff] [blame] | 907 | SetUpForTest(false, "getSinkPropertiesNative", "(Ljava/lang/String;)[Ljava/lang/Object;", |
| 908 | reinterpret_cast<void*>(&Java_MyClassNatives_GetSinkProperties)); |
| 909 | |
| 910 | EXPECT_EQ(0, gJava_MyClassNatives_GetSinkProperties_calls); |
| 911 | jarray result = down_cast<jarray>( |
| 912 | env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, nullptr)); |
| 913 | EXPECT_EQ(nullptr, result); |
| 914 | EXPECT_EQ(1, gJava_MyClassNatives_GetSinkProperties_calls); |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 915 | |
| 916 | gJava_MyClassNatives_GetSinkProperties_calls = 0; |
Brian Carlstrom | fc7120c | 2012-08-27 13:43:25 -0700 | [diff] [blame] | 917 | } |
| 918 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 919 | JNI_TEST(GetSinkPropertiesNative) |
| 920 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 921 | // This should return jclass, but we're imitating a bug pattern. |
| 922 | jobject Java_MyClassNatives_instanceMethodThatShouldReturnClass(JNIEnv* env, jobject) { |
| 923 | return env->NewStringUTF("not a class!"); |
| 924 | } |
| 925 | |
| 926 | // This should return jclass, but we're imitating a bug pattern. |
| 927 | jobject Java_MyClassNatives_staticMethodThatShouldReturnClass(JNIEnv* env, jclass) { |
| 928 | return env->NewStringUTF("not a class!"); |
| 929 | } |
| 930 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 931 | void JniCompilerTest::UpcallReturnTypeChecking_InstanceImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 932 | SetUpForTest(false, "instanceMethodThatShouldReturnClass", "()Ljava/lang/Class;", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 933 | reinterpret_cast<void*>(&Java_MyClassNatives_instanceMethodThatShouldReturnClass)); |
| 934 | |
| 935 | CheckJniAbortCatcher check_jni_abort_catcher; |
Elliott Hughes | 3f6635a | 2012-06-19 13:37:49 -0700 | [diff] [blame] | 936 | // This native method is bad, and tries to return a jstring as a jclass. |
| 937 | env_->CallObjectMethod(jobj_, jmethod_); |
| 938 | check_jni_abort_catcher.Check("attempt to return an instance of java.lang.String from java.lang.Class MyClassNatives.instanceMethodThatShouldReturnClass()"); |
| 939 | |
| 940 | // Here, we just call the method incorrectly; we should catch that too. |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 941 | env_->CallObjectMethod(jobj_, jmethod_); |
Elliott Hughes | 3f6635a | 2012-06-19 13:37:49 -0700 | [diff] [blame] | 942 | check_jni_abort_catcher.Check("attempt to return an instance of java.lang.String from java.lang.Class MyClassNatives.instanceMethodThatShouldReturnClass()"); |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 943 | env_->CallStaticObjectMethod(jklass_, jmethod_); |
| 944 | check_jni_abort_catcher.Check("calling non-static method java.lang.Class MyClassNatives.instanceMethodThatShouldReturnClass() with CallStaticObjectMethodV"); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 945 | } |
| 946 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 947 | JNI_TEST(UpcallReturnTypeChecking_Instance) |
| 948 | |
| 949 | void JniCompilerTest::UpcallReturnTypeChecking_StaticImpl() { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 950 | SetUpForTest(true, "staticMethodThatShouldReturnClass", "()Ljava/lang/Class;", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 951 | reinterpret_cast<void*>(&Java_MyClassNatives_staticMethodThatShouldReturnClass)); |
| 952 | |
| 953 | CheckJniAbortCatcher check_jni_abort_catcher; |
Elliott Hughes | 3f6635a | 2012-06-19 13:37:49 -0700 | [diff] [blame] | 954 | // This native method is bad, and tries to return a jstring as a jclass. |
| 955 | env_->CallStaticObjectMethod(jklass_, jmethod_); |
| 956 | check_jni_abort_catcher.Check("attempt to return an instance of java.lang.String from java.lang.Class MyClassNatives.staticMethodThatShouldReturnClass()"); |
| 957 | |
| 958 | // Here, we just call the method incorrectly; we should catch that too. |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 959 | env_->CallStaticObjectMethod(jklass_, jmethod_); |
Elliott Hughes | 3f6635a | 2012-06-19 13:37:49 -0700 | [diff] [blame] | 960 | check_jni_abort_catcher.Check("attempt to return an instance of java.lang.String from java.lang.Class MyClassNatives.staticMethodThatShouldReturnClass()"); |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 961 | env_->CallObjectMethod(jobj_, jmethod_); |
| 962 | check_jni_abort_catcher.Check("calling static method java.lang.Class MyClassNatives.staticMethodThatShouldReturnClass() with CallObjectMethodV"); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 963 | } |
| 964 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 965 | JNI_TEST(UpcallReturnTypeChecking_Static) |
| 966 | |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 967 | // This should take jclass, but we're imitating a bug pattern. |
| 968 | void Java_MyClassNatives_instanceMethodThatShouldTakeClass(JNIEnv*, jobject, jclass) { |
| 969 | } |
| 970 | |
| 971 | // This should take jclass, but we're imitating a bug pattern. |
| 972 | void Java_MyClassNatives_staticMethodThatShouldTakeClass(JNIEnv*, jclass, jclass) { |
| 973 | } |
| 974 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 975 | void JniCompilerTest::UpcallArgumentTypeChecking_InstanceImpl() { |
Andreas Gampe | 369810a | 2015-01-14 19:53:31 -0800 | [diff] [blame] | 976 | // This will lead to error messages in the log. |
| 977 | ScopedLogSeverity sls(LogSeverity::FATAL); |
| 978 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 979 | SetUpForTest(false, "instanceMethodThatShouldTakeClass", "(ILjava/lang/Class;)V", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 980 | reinterpret_cast<void*>(&Java_MyClassNatives_instanceMethodThatShouldTakeClass)); |
| 981 | |
| 982 | CheckJniAbortCatcher check_jni_abort_catcher; |
| 983 | // We deliberately pass a bad second argument here. |
| 984 | env_->CallVoidMethod(jobj_, jmethod_, 123, env_->NewStringUTF("not a class!")); |
Elliott Hughes | 3f6635a | 2012-06-19 13:37:49 -0700 | [diff] [blame] | 985 | check_jni_abort_catcher.Check("bad arguments passed to void MyClassNatives.instanceMethodThatShouldTakeClass(int, java.lang.Class)"); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 986 | } |
| 987 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 988 | JNI_TEST(UpcallArgumentTypeChecking_Instance) |
| 989 | |
| 990 | void JniCompilerTest::UpcallArgumentTypeChecking_StaticImpl() { |
Andreas Gampe | 369810a | 2015-01-14 19:53:31 -0800 | [diff] [blame] | 991 | // This will lead to error messages in the log. |
| 992 | ScopedLogSeverity sls(LogSeverity::FATAL); |
| 993 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 994 | SetUpForTest(true, "staticMethodThatShouldTakeClass", "(ILjava/lang/Class;)V", |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 995 | reinterpret_cast<void*>(&Java_MyClassNatives_staticMethodThatShouldTakeClass)); |
| 996 | |
| 997 | CheckJniAbortCatcher check_jni_abort_catcher; |
| 998 | // We deliberately pass a bad second argument here. |
| 999 | env_->CallStaticVoidMethod(jklass_, jmethod_, 123, env_->NewStringUTF("not a class!")); |
Elliott Hughes | 3f6635a | 2012-06-19 13:37:49 -0700 | [diff] [blame] | 1000 | check_jni_abort_catcher.Check("bad arguments passed to void MyClassNatives.staticMethodThatShouldTakeClass(int, java.lang.Class)"); |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 1001 | } |
| 1002 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1003 | JNI_TEST(UpcallArgumentTypeChecking_Static) |
| 1004 | |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1005 | jfloat Java_MyClassNatives_checkFloats(JNIEnv* env, jobject thisObj, jfloat f1, jfloat f2) { |
| 1006 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
| 1007 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1008 | EXPECT_TRUE(thisObj != nullptr); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1009 | EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_)); |
| 1010 | ScopedObjectAccess soa(Thread::Current()); |
| 1011 | EXPECT_EQ(1U, Thread::Current()->NumStackReferences()); |
| 1012 | return f1 - f2; // non-commutative operator |
| 1013 | } |
| 1014 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1015 | void JniCompilerTest::CompileAndRunFloatFloatMethodImpl() { |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1016 | SetUpForTest(false, "checkFloats", "(FF)F", |
| 1017 | reinterpret_cast<void*>(&Java_MyClassNatives_checkFloats)); |
| 1018 | |
| 1019 | jfloat result = env_->CallNonvirtualFloatMethod(jobj_, jklass_, jmethod_, |
| 1020 | 99.0F, 10.0F); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 1021 | EXPECT_FLOAT_EQ(99.0F - 10.0F, result); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1022 | jfloat a = 3.14159F; |
| 1023 | jfloat b = 0.69314F; |
| 1024 | result = env_->CallNonvirtualFloatMethod(jobj_, jklass_, jmethod_, a, b); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 1025 | EXPECT_FLOAT_EQ(a - b, result); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1026 | } |
| 1027 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1028 | JNI_TEST(CompileAndRunFloatFloatMethod) |
| 1029 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 1030 | void Java_MyClassNatives_checkParameterAlign(JNIEnv* env ATTRIBUTE_UNUSED, |
| 1031 | jobject thisObj ATTRIBUTE_UNUSED, |
| 1032 | jint i1 ATTRIBUTE_UNUSED, |
| 1033 | jlong l1 ATTRIBUTE_UNUSED) { |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1034 | // EXPECT_EQ(kNative, Thread::Current()->GetState()); |
| 1035 | // EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
| 1036 | // EXPECT_TRUE(thisObj != nullptr); |
| 1037 | // EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_)); |
| 1038 | // ScopedObjectAccess soa(Thread::Current()); |
| 1039 | // EXPECT_EQ(1U, Thread::Current()->NumStackReferences()); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1040 | EXPECT_EQ(i1, 1234); |
Ian Rogers | 0f67847 | 2014-03-10 16:18:37 -0700 | [diff] [blame] | 1041 | EXPECT_EQ(l1, INT64_C(0x12345678ABCDEF0)); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1042 | } |
| 1043 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1044 | void JniCompilerTest::CheckParameterAlignImpl() { |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1045 | SetUpForTest(false, "checkParameterAlign", "(IJ)V", |
| 1046 | reinterpret_cast<void*>(&Java_MyClassNatives_checkParameterAlign)); |
| 1047 | |
Ian Rogers | 0f67847 | 2014-03-10 16:18:37 -0700 | [diff] [blame] | 1048 | env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_, 1234, INT64_C(0x12345678ABCDEF0)); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1049 | } |
| 1050 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1051 | JNI_TEST(CheckParameterAlign) |
| 1052 | |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1053 | void Java_MyClassNatives_maxParamNumber(JNIEnv* env, jobject thisObj, |
| 1054 | jobject o0, jobject o1, jobject o2, jobject o3, jobject o4, jobject o5, jobject o6, jobject o7, |
| 1055 | jobject o8, jobject o9, jobject o10, jobject o11, jobject o12, jobject o13, jobject o14, jobject o15, |
| 1056 | jobject o16, jobject o17, jobject o18, jobject o19, jobject o20, jobject o21, jobject o22, jobject o23, |
| 1057 | jobject o24, jobject o25, jobject o26, jobject o27, jobject o28, jobject o29, jobject o30, jobject o31, |
| 1058 | jobject o32, jobject o33, jobject o34, jobject o35, jobject o36, jobject o37, jobject o38, jobject o39, |
| 1059 | jobject o40, jobject o41, jobject o42, jobject o43, jobject o44, jobject o45, jobject o46, jobject o47, |
| 1060 | jobject o48, jobject o49, jobject o50, jobject o51, jobject o52, jobject o53, jobject o54, jobject o55, |
| 1061 | jobject o56, jobject o57, jobject o58, jobject o59, jobject o60, jobject o61, jobject o62, jobject o63, |
| 1062 | jobject o64, jobject o65, jobject o66, jobject o67, jobject o68, jobject o69, jobject o70, jobject o71, |
| 1063 | jobject o72, jobject o73, jobject o74, jobject o75, jobject o76, jobject o77, jobject o78, jobject o79, |
| 1064 | jobject o80, jobject o81, jobject o82, jobject o83, jobject o84, jobject o85, jobject o86, jobject o87, |
| 1065 | jobject o88, jobject o89, jobject o90, jobject o91, jobject o92, jobject o93, jobject o94, jobject o95, |
| 1066 | jobject o96, jobject o97, jobject o98, jobject o99, jobject o100, jobject o101, jobject o102, jobject o103, |
| 1067 | jobject o104, jobject o105, jobject o106, jobject o107, jobject o108, jobject o109, jobject o110, jobject o111, |
| 1068 | jobject o112, jobject o113, jobject o114, jobject o115, jobject o116, jobject o117, jobject o118, jobject o119, |
| 1069 | jobject o120, jobject o121, jobject o122, jobject o123, jobject o124, jobject o125, jobject o126, jobject o127, |
| 1070 | jobject o128, jobject o129, jobject o130, jobject o131, jobject o132, jobject o133, jobject o134, jobject o135, |
| 1071 | jobject o136, jobject o137, jobject o138, jobject o139, jobject o140, jobject o141, jobject o142, jobject o143, |
| 1072 | jobject o144, jobject o145, jobject o146, jobject o147, jobject o148, jobject o149, jobject o150, jobject o151, |
| 1073 | jobject o152, jobject o153, jobject o154, jobject o155, jobject o156, jobject o157, jobject o158, jobject o159, |
| 1074 | jobject o160, jobject o161, jobject o162, jobject o163, jobject o164, jobject o165, jobject o166, jobject o167, |
| 1075 | jobject o168, jobject o169, jobject o170, jobject o171, jobject o172, jobject o173, jobject o174, jobject o175, |
| 1076 | jobject o176, jobject o177, jobject o178, jobject o179, jobject o180, jobject o181, jobject o182, jobject o183, |
| 1077 | jobject o184, jobject o185, jobject o186, jobject o187, jobject o188, jobject o189, jobject o190, jobject o191, |
| 1078 | jobject o192, jobject o193, jobject o194, jobject o195, jobject o196, jobject o197, jobject o198, jobject o199, |
| 1079 | jobject o200, jobject o201, jobject o202, jobject o203, jobject o204, jobject o205, jobject o206, jobject o207, |
| 1080 | jobject o208, jobject o209, jobject o210, jobject o211, jobject o212, jobject o213, jobject o214, jobject o215, |
| 1081 | jobject o216, jobject o217, jobject o218, jobject o219, jobject o220, jobject o221, jobject o222, jobject o223, |
| 1082 | jobject o224, jobject o225, jobject o226, jobject o227, jobject o228, jobject o229, jobject o230, jobject o231, |
| 1083 | jobject o232, jobject o233, jobject o234, jobject o235, jobject o236, jobject o237, jobject o238, jobject o239, |
| 1084 | jobject o240, jobject o241, jobject o242, jobject o243, jobject o244, jobject o245, jobject o246, jobject o247, |
| 1085 | jobject o248, jobject o249, jobject o250, jobject o251, jobject o252, jobject o253) { |
| 1086 | EXPECT_EQ(kNative, Thread::Current()->GetState()); |
| 1087 | EXPECT_EQ(Thread::Current()->GetJniEnv(), env); |
Andreas Gampe | cf4035a | 2014-05-28 22:43:01 -0700 | [diff] [blame] | 1088 | EXPECT_TRUE(thisObj != nullptr); |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1089 | EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_)); |
| 1090 | ScopedObjectAccess soa(Thread::Current()); |
| 1091 | EXPECT_GE(255U, Thread::Current()->NumStackReferences()); |
| 1092 | |
| 1093 | // two tests possible |
| 1094 | if (o0 == nullptr) { |
| 1095 | // 1) everything is null |
| 1096 | EXPECT_TRUE(o0 == nullptr && o1 == nullptr && o2 == nullptr && o3 == nullptr && o4 == nullptr |
| 1097 | && o5 == nullptr && o6 == nullptr && o7 == nullptr && o8 == nullptr && o9 == nullptr |
| 1098 | && o10 == nullptr && o11 == nullptr && o12 == nullptr && o13 == nullptr && o14 == nullptr |
| 1099 | && o15 == nullptr && o16 == nullptr && o17 == nullptr && o18 == nullptr && o19 == nullptr |
| 1100 | && o20 == nullptr && o21 == nullptr && o22 == nullptr && o23 == nullptr && o24 == nullptr |
| 1101 | && o25 == nullptr && o26 == nullptr && o27 == nullptr && o28 == nullptr && o29 == nullptr |
| 1102 | && o30 == nullptr && o31 == nullptr && o32 == nullptr && o33 == nullptr && o34 == nullptr |
| 1103 | && o35 == nullptr && o36 == nullptr && o37 == nullptr && o38 == nullptr && o39 == nullptr |
| 1104 | && o40 == nullptr && o41 == nullptr && o42 == nullptr && o43 == nullptr && o44 == nullptr |
| 1105 | && o45 == nullptr && o46 == nullptr && o47 == nullptr && o48 == nullptr && o49 == nullptr |
| 1106 | && o50 == nullptr && o51 == nullptr && o52 == nullptr && o53 == nullptr && o54 == nullptr |
| 1107 | && o55 == nullptr && o56 == nullptr && o57 == nullptr && o58 == nullptr && o59 == nullptr |
| 1108 | && o60 == nullptr && o61 == nullptr && o62 == nullptr && o63 == nullptr && o64 == nullptr |
| 1109 | && o65 == nullptr && o66 == nullptr && o67 == nullptr && o68 == nullptr && o69 == nullptr |
| 1110 | && o70 == nullptr && o71 == nullptr && o72 == nullptr && o73 == nullptr && o74 == nullptr |
| 1111 | && o75 == nullptr && o76 == nullptr && o77 == nullptr && o78 == nullptr && o79 == nullptr |
| 1112 | && o80 == nullptr && o81 == nullptr && o82 == nullptr && o83 == nullptr && o84 == nullptr |
| 1113 | && o85 == nullptr && o86 == nullptr && o87 == nullptr && o88 == nullptr && o89 == nullptr |
| 1114 | && o90 == nullptr && o91 == nullptr && o92 == nullptr && o93 == nullptr && o94 == nullptr |
| 1115 | && o95 == nullptr && o96 == nullptr && o97 == nullptr && o98 == nullptr && o99 == nullptr |
| 1116 | && o100 == nullptr && o101 == nullptr && o102 == nullptr && o103 == nullptr && o104 == nullptr |
| 1117 | && o105 == nullptr && o106 == nullptr && o107 == nullptr && o108 == nullptr && o109 == nullptr |
| 1118 | && o110 == nullptr && o111 == nullptr && o112 == nullptr && o113 == nullptr && o114 == nullptr |
| 1119 | && o115 == nullptr && o116 == nullptr && o117 == nullptr && o118 == nullptr && o119 == nullptr |
| 1120 | && o120 == nullptr && o121 == nullptr && o122 == nullptr && o123 == nullptr && o124 == nullptr |
| 1121 | && o125 == nullptr && o126 == nullptr && o127 == nullptr && o128 == nullptr && o129 == nullptr |
| 1122 | && o130 == nullptr && o131 == nullptr && o132 == nullptr && o133 == nullptr && o134 == nullptr |
| 1123 | && o135 == nullptr && o136 == nullptr && o137 == nullptr && o138 == nullptr && o139 == nullptr |
| 1124 | && o140 == nullptr && o141 == nullptr && o142 == nullptr && o143 == nullptr && o144 == nullptr |
| 1125 | && o145 == nullptr && o146 == nullptr && o147 == nullptr && o148 == nullptr && o149 == nullptr |
| 1126 | && o150 == nullptr && o151 == nullptr && o152 == nullptr && o153 == nullptr && o154 == nullptr |
| 1127 | && o155 == nullptr && o156 == nullptr && o157 == nullptr && o158 == nullptr && o159 == nullptr |
| 1128 | && o160 == nullptr && o161 == nullptr && o162 == nullptr && o163 == nullptr && o164 == nullptr |
| 1129 | && o165 == nullptr && o166 == nullptr && o167 == nullptr && o168 == nullptr && o169 == nullptr |
| 1130 | && o170 == nullptr && o171 == nullptr && o172 == nullptr && o173 == nullptr && o174 == nullptr |
| 1131 | && o175 == nullptr && o176 == nullptr && o177 == nullptr && o178 == nullptr && o179 == nullptr |
| 1132 | && o180 == nullptr && o181 == nullptr && o182 == nullptr && o183 == nullptr && o184 == nullptr |
| 1133 | && o185 == nullptr && o186 == nullptr && o187 == nullptr && o188 == nullptr && o189 == nullptr |
| 1134 | && o190 == nullptr && o191 == nullptr && o192 == nullptr && o193 == nullptr && o194 == nullptr |
| 1135 | && o195 == nullptr && o196 == nullptr && o197 == nullptr && o198 == nullptr && o199 == nullptr |
| 1136 | && o200 == nullptr && o201 == nullptr && o202 == nullptr && o203 == nullptr && o204 == nullptr |
| 1137 | && o205 == nullptr && o206 == nullptr && o207 == nullptr && o208 == nullptr && o209 == nullptr |
| 1138 | && o210 == nullptr && o211 == nullptr && o212 == nullptr && o213 == nullptr && o214 == nullptr |
| 1139 | && o215 == nullptr && o216 == nullptr && o217 == nullptr && o218 == nullptr && o219 == nullptr |
| 1140 | && o220 == nullptr && o221 == nullptr && o222 == nullptr && o223 == nullptr && o224 == nullptr |
| 1141 | && o225 == nullptr && o226 == nullptr && o227 == nullptr && o228 == nullptr && o229 == nullptr |
| 1142 | && o230 == nullptr && o231 == nullptr && o232 == nullptr && o233 == nullptr && o234 == nullptr |
| 1143 | && o235 == nullptr && o236 == nullptr && o237 == nullptr && o238 == nullptr && o239 == nullptr |
| 1144 | && o240 == nullptr && o241 == nullptr && o242 == nullptr && o243 == nullptr && o244 == nullptr |
| 1145 | && o245 == nullptr && o246 == nullptr && o247 == nullptr && o248 == nullptr && o249 == nullptr |
| 1146 | && o250 == nullptr && o251 == nullptr && o252 == nullptr && o253 == nullptr); |
| 1147 | } else { |
| 1148 | EXPECT_EQ(0, env->GetArrayLength(reinterpret_cast<jarray>(o0))); |
| 1149 | EXPECT_EQ(1, env->GetArrayLength(reinterpret_cast<jarray>(o1))); |
| 1150 | EXPECT_EQ(2, env->GetArrayLength(reinterpret_cast<jarray>(o2))); |
| 1151 | EXPECT_EQ(3, env->GetArrayLength(reinterpret_cast<jarray>(o3))); |
| 1152 | EXPECT_EQ(4, env->GetArrayLength(reinterpret_cast<jarray>(o4))); |
| 1153 | EXPECT_EQ(5, env->GetArrayLength(reinterpret_cast<jarray>(o5))); |
| 1154 | EXPECT_EQ(6, env->GetArrayLength(reinterpret_cast<jarray>(o6))); |
| 1155 | EXPECT_EQ(7, env->GetArrayLength(reinterpret_cast<jarray>(o7))); |
| 1156 | EXPECT_EQ(8, env->GetArrayLength(reinterpret_cast<jarray>(o8))); |
| 1157 | EXPECT_EQ(9, env->GetArrayLength(reinterpret_cast<jarray>(o9))); |
| 1158 | EXPECT_EQ(10, env->GetArrayLength(reinterpret_cast<jarray>(o10))); |
| 1159 | EXPECT_EQ(11, env->GetArrayLength(reinterpret_cast<jarray>(o11))); |
| 1160 | EXPECT_EQ(12, env->GetArrayLength(reinterpret_cast<jarray>(o12))); |
| 1161 | EXPECT_EQ(13, env->GetArrayLength(reinterpret_cast<jarray>(o13))); |
| 1162 | EXPECT_EQ(14, env->GetArrayLength(reinterpret_cast<jarray>(o14))); |
| 1163 | EXPECT_EQ(15, env->GetArrayLength(reinterpret_cast<jarray>(o15))); |
| 1164 | EXPECT_EQ(16, env->GetArrayLength(reinterpret_cast<jarray>(o16))); |
| 1165 | EXPECT_EQ(17, env->GetArrayLength(reinterpret_cast<jarray>(o17))); |
| 1166 | EXPECT_EQ(18, env->GetArrayLength(reinterpret_cast<jarray>(o18))); |
| 1167 | EXPECT_EQ(19, env->GetArrayLength(reinterpret_cast<jarray>(o19))); |
| 1168 | EXPECT_EQ(20, env->GetArrayLength(reinterpret_cast<jarray>(o20))); |
| 1169 | EXPECT_EQ(21, env->GetArrayLength(reinterpret_cast<jarray>(o21))); |
| 1170 | EXPECT_EQ(22, env->GetArrayLength(reinterpret_cast<jarray>(o22))); |
| 1171 | EXPECT_EQ(23, env->GetArrayLength(reinterpret_cast<jarray>(o23))); |
| 1172 | EXPECT_EQ(24, env->GetArrayLength(reinterpret_cast<jarray>(o24))); |
| 1173 | EXPECT_EQ(25, env->GetArrayLength(reinterpret_cast<jarray>(o25))); |
| 1174 | EXPECT_EQ(26, env->GetArrayLength(reinterpret_cast<jarray>(o26))); |
| 1175 | EXPECT_EQ(27, env->GetArrayLength(reinterpret_cast<jarray>(o27))); |
| 1176 | EXPECT_EQ(28, env->GetArrayLength(reinterpret_cast<jarray>(o28))); |
| 1177 | EXPECT_EQ(29, env->GetArrayLength(reinterpret_cast<jarray>(o29))); |
| 1178 | EXPECT_EQ(30, env->GetArrayLength(reinterpret_cast<jarray>(o30))); |
| 1179 | EXPECT_EQ(31, env->GetArrayLength(reinterpret_cast<jarray>(o31))); |
| 1180 | EXPECT_EQ(32, env->GetArrayLength(reinterpret_cast<jarray>(o32))); |
| 1181 | EXPECT_EQ(33, env->GetArrayLength(reinterpret_cast<jarray>(o33))); |
| 1182 | EXPECT_EQ(34, env->GetArrayLength(reinterpret_cast<jarray>(o34))); |
| 1183 | EXPECT_EQ(35, env->GetArrayLength(reinterpret_cast<jarray>(o35))); |
| 1184 | EXPECT_EQ(36, env->GetArrayLength(reinterpret_cast<jarray>(o36))); |
| 1185 | EXPECT_EQ(37, env->GetArrayLength(reinterpret_cast<jarray>(o37))); |
| 1186 | EXPECT_EQ(38, env->GetArrayLength(reinterpret_cast<jarray>(o38))); |
| 1187 | EXPECT_EQ(39, env->GetArrayLength(reinterpret_cast<jarray>(o39))); |
| 1188 | EXPECT_EQ(40, env->GetArrayLength(reinterpret_cast<jarray>(o40))); |
| 1189 | EXPECT_EQ(41, env->GetArrayLength(reinterpret_cast<jarray>(o41))); |
| 1190 | EXPECT_EQ(42, env->GetArrayLength(reinterpret_cast<jarray>(o42))); |
| 1191 | EXPECT_EQ(43, env->GetArrayLength(reinterpret_cast<jarray>(o43))); |
| 1192 | EXPECT_EQ(44, env->GetArrayLength(reinterpret_cast<jarray>(o44))); |
| 1193 | EXPECT_EQ(45, env->GetArrayLength(reinterpret_cast<jarray>(o45))); |
| 1194 | EXPECT_EQ(46, env->GetArrayLength(reinterpret_cast<jarray>(o46))); |
| 1195 | EXPECT_EQ(47, env->GetArrayLength(reinterpret_cast<jarray>(o47))); |
| 1196 | EXPECT_EQ(48, env->GetArrayLength(reinterpret_cast<jarray>(o48))); |
| 1197 | EXPECT_EQ(49, env->GetArrayLength(reinterpret_cast<jarray>(o49))); |
| 1198 | EXPECT_EQ(50, env->GetArrayLength(reinterpret_cast<jarray>(o50))); |
| 1199 | EXPECT_EQ(51, env->GetArrayLength(reinterpret_cast<jarray>(o51))); |
| 1200 | EXPECT_EQ(52, env->GetArrayLength(reinterpret_cast<jarray>(o52))); |
| 1201 | EXPECT_EQ(53, env->GetArrayLength(reinterpret_cast<jarray>(o53))); |
| 1202 | EXPECT_EQ(54, env->GetArrayLength(reinterpret_cast<jarray>(o54))); |
| 1203 | EXPECT_EQ(55, env->GetArrayLength(reinterpret_cast<jarray>(o55))); |
| 1204 | EXPECT_EQ(56, env->GetArrayLength(reinterpret_cast<jarray>(o56))); |
| 1205 | EXPECT_EQ(57, env->GetArrayLength(reinterpret_cast<jarray>(o57))); |
| 1206 | EXPECT_EQ(58, env->GetArrayLength(reinterpret_cast<jarray>(o58))); |
| 1207 | EXPECT_EQ(59, env->GetArrayLength(reinterpret_cast<jarray>(o59))); |
| 1208 | EXPECT_EQ(60, env->GetArrayLength(reinterpret_cast<jarray>(o60))); |
| 1209 | EXPECT_EQ(61, env->GetArrayLength(reinterpret_cast<jarray>(o61))); |
| 1210 | EXPECT_EQ(62, env->GetArrayLength(reinterpret_cast<jarray>(o62))); |
| 1211 | EXPECT_EQ(63, env->GetArrayLength(reinterpret_cast<jarray>(o63))); |
| 1212 | EXPECT_EQ(64, env->GetArrayLength(reinterpret_cast<jarray>(o64))); |
| 1213 | EXPECT_EQ(65, env->GetArrayLength(reinterpret_cast<jarray>(o65))); |
| 1214 | EXPECT_EQ(66, env->GetArrayLength(reinterpret_cast<jarray>(o66))); |
| 1215 | EXPECT_EQ(67, env->GetArrayLength(reinterpret_cast<jarray>(o67))); |
| 1216 | EXPECT_EQ(68, env->GetArrayLength(reinterpret_cast<jarray>(o68))); |
| 1217 | EXPECT_EQ(69, env->GetArrayLength(reinterpret_cast<jarray>(o69))); |
| 1218 | EXPECT_EQ(70, env->GetArrayLength(reinterpret_cast<jarray>(o70))); |
| 1219 | EXPECT_EQ(71, env->GetArrayLength(reinterpret_cast<jarray>(o71))); |
| 1220 | EXPECT_EQ(72, env->GetArrayLength(reinterpret_cast<jarray>(o72))); |
| 1221 | EXPECT_EQ(73, env->GetArrayLength(reinterpret_cast<jarray>(o73))); |
| 1222 | EXPECT_EQ(74, env->GetArrayLength(reinterpret_cast<jarray>(o74))); |
| 1223 | EXPECT_EQ(75, env->GetArrayLength(reinterpret_cast<jarray>(o75))); |
| 1224 | EXPECT_EQ(76, env->GetArrayLength(reinterpret_cast<jarray>(o76))); |
| 1225 | EXPECT_EQ(77, env->GetArrayLength(reinterpret_cast<jarray>(o77))); |
| 1226 | EXPECT_EQ(78, env->GetArrayLength(reinterpret_cast<jarray>(o78))); |
| 1227 | EXPECT_EQ(79, env->GetArrayLength(reinterpret_cast<jarray>(o79))); |
| 1228 | EXPECT_EQ(80, env->GetArrayLength(reinterpret_cast<jarray>(o80))); |
| 1229 | EXPECT_EQ(81, env->GetArrayLength(reinterpret_cast<jarray>(o81))); |
| 1230 | EXPECT_EQ(82, env->GetArrayLength(reinterpret_cast<jarray>(o82))); |
| 1231 | EXPECT_EQ(83, env->GetArrayLength(reinterpret_cast<jarray>(o83))); |
| 1232 | EXPECT_EQ(84, env->GetArrayLength(reinterpret_cast<jarray>(o84))); |
| 1233 | EXPECT_EQ(85, env->GetArrayLength(reinterpret_cast<jarray>(o85))); |
| 1234 | EXPECT_EQ(86, env->GetArrayLength(reinterpret_cast<jarray>(o86))); |
| 1235 | EXPECT_EQ(87, env->GetArrayLength(reinterpret_cast<jarray>(o87))); |
| 1236 | EXPECT_EQ(88, env->GetArrayLength(reinterpret_cast<jarray>(o88))); |
| 1237 | EXPECT_EQ(89, env->GetArrayLength(reinterpret_cast<jarray>(o89))); |
| 1238 | EXPECT_EQ(90, env->GetArrayLength(reinterpret_cast<jarray>(o90))); |
| 1239 | EXPECT_EQ(91, env->GetArrayLength(reinterpret_cast<jarray>(o91))); |
| 1240 | EXPECT_EQ(92, env->GetArrayLength(reinterpret_cast<jarray>(o92))); |
| 1241 | EXPECT_EQ(93, env->GetArrayLength(reinterpret_cast<jarray>(o93))); |
| 1242 | EXPECT_EQ(94, env->GetArrayLength(reinterpret_cast<jarray>(o94))); |
| 1243 | EXPECT_EQ(95, env->GetArrayLength(reinterpret_cast<jarray>(o95))); |
| 1244 | EXPECT_EQ(96, env->GetArrayLength(reinterpret_cast<jarray>(o96))); |
| 1245 | EXPECT_EQ(97, env->GetArrayLength(reinterpret_cast<jarray>(o97))); |
| 1246 | EXPECT_EQ(98, env->GetArrayLength(reinterpret_cast<jarray>(o98))); |
| 1247 | EXPECT_EQ(99, env->GetArrayLength(reinterpret_cast<jarray>(o99))); |
| 1248 | EXPECT_EQ(100, env->GetArrayLength(reinterpret_cast<jarray>(o100))); |
| 1249 | EXPECT_EQ(101, env->GetArrayLength(reinterpret_cast<jarray>(o101))); |
| 1250 | EXPECT_EQ(102, env->GetArrayLength(reinterpret_cast<jarray>(o102))); |
| 1251 | EXPECT_EQ(103, env->GetArrayLength(reinterpret_cast<jarray>(o103))); |
| 1252 | EXPECT_EQ(104, env->GetArrayLength(reinterpret_cast<jarray>(o104))); |
| 1253 | EXPECT_EQ(105, env->GetArrayLength(reinterpret_cast<jarray>(o105))); |
| 1254 | EXPECT_EQ(106, env->GetArrayLength(reinterpret_cast<jarray>(o106))); |
| 1255 | EXPECT_EQ(107, env->GetArrayLength(reinterpret_cast<jarray>(o107))); |
| 1256 | EXPECT_EQ(108, env->GetArrayLength(reinterpret_cast<jarray>(o108))); |
| 1257 | EXPECT_EQ(109, env->GetArrayLength(reinterpret_cast<jarray>(o109))); |
| 1258 | EXPECT_EQ(110, env->GetArrayLength(reinterpret_cast<jarray>(o110))); |
| 1259 | EXPECT_EQ(111, env->GetArrayLength(reinterpret_cast<jarray>(o111))); |
| 1260 | EXPECT_EQ(112, env->GetArrayLength(reinterpret_cast<jarray>(o112))); |
| 1261 | EXPECT_EQ(113, env->GetArrayLength(reinterpret_cast<jarray>(o113))); |
| 1262 | EXPECT_EQ(114, env->GetArrayLength(reinterpret_cast<jarray>(o114))); |
| 1263 | EXPECT_EQ(115, env->GetArrayLength(reinterpret_cast<jarray>(o115))); |
| 1264 | EXPECT_EQ(116, env->GetArrayLength(reinterpret_cast<jarray>(o116))); |
| 1265 | EXPECT_EQ(117, env->GetArrayLength(reinterpret_cast<jarray>(o117))); |
| 1266 | EXPECT_EQ(118, env->GetArrayLength(reinterpret_cast<jarray>(o118))); |
| 1267 | EXPECT_EQ(119, env->GetArrayLength(reinterpret_cast<jarray>(o119))); |
| 1268 | EXPECT_EQ(120, env->GetArrayLength(reinterpret_cast<jarray>(o120))); |
| 1269 | EXPECT_EQ(121, env->GetArrayLength(reinterpret_cast<jarray>(o121))); |
| 1270 | EXPECT_EQ(122, env->GetArrayLength(reinterpret_cast<jarray>(o122))); |
| 1271 | EXPECT_EQ(123, env->GetArrayLength(reinterpret_cast<jarray>(o123))); |
| 1272 | EXPECT_EQ(124, env->GetArrayLength(reinterpret_cast<jarray>(o124))); |
| 1273 | EXPECT_EQ(125, env->GetArrayLength(reinterpret_cast<jarray>(o125))); |
| 1274 | EXPECT_EQ(126, env->GetArrayLength(reinterpret_cast<jarray>(o126))); |
| 1275 | EXPECT_EQ(127, env->GetArrayLength(reinterpret_cast<jarray>(o127))); |
| 1276 | EXPECT_EQ(128, env->GetArrayLength(reinterpret_cast<jarray>(o128))); |
| 1277 | EXPECT_EQ(129, env->GetArrayLength(reinterpret_cast<jarray>(o129))); |
| 1278 | EXPECT_EQ(130, env->GetArrayLength(reinterpret_cast<jarray>(o130))); |
| 1279 | EXPECT_EQ(131, env->GetArrayLength(reinterpret_cast<jarray>(o131))); |
| 1280 | EXPECT_EQ(132, env->GetArrayLength(reinterpret_cast<jarray>(o132))); |
| 1281 | EXPECT_EQ(133, env->GetArrayLength(reinterpret_cast<jarray>(o133))); |
| 1282 | EXPECT_EQ(134, env->GetArrayLength(reinterpret_cast<jarray>(o134))); |
| 1283 | EXPECT_EQ(135, env->GetArrayLength(reinterpret_cast<jarray>(o135))); |
| 1284 | EXPECT_EQ(136, env->GetArrayLength(reinterpret_cast<jarray>(o136))); |
| 1285 | EXPECT_EQ(137, env->GetArrayLength(reinterpret_cast<jarray>(o137))); |
| 1286 | EXPECT_EQ(138, env->GetArrayLength(reinterpret_cast<jarray>(o138))); |
| 1287 | EXPECT_EQ(139, env->GetArrayLength(reinterpret_cast<jarray>(o139))); |
| 1288 | EXPECT_EQ(140, env->GetArrayLength(reinterpret_cast<jarray>(o140))); |
| 1289 | EXPECT_EQ(141, env->GetArrayLength(reinterpret_cast<jarray>(o141))); |
| 1290 | EXPECT_EQ(142, env->GetArrayLength(reinterpret_cast<jarray>(o142))); |
| 1291 | EXPECT_EQ(143, env->GetArrayLength(reinterpret_cast<jarray>(o143))); |
| 1292 | EXPECT_EQ(144, env->GetArrayLength(reinterpret_cast<jarray>(o144))); |
| 1293 | EXPECT_EQ(145, env->GetArrayLength(reinterpret_cast<jarray>(o145))); |
| 1294 | EXPECT_EQ(146, env->GetArrayLength(reinterpret_cast<jarray>(o146))); |
| 1295 | EXPECT_EQ(147, env->GetArrayLength(reinterpret_cast<jarray>(o147))); |
| 1296 | EXPECT_EQ(148, env->GetArrayLength(reinterpret_cast<jarray>(o148))); |
| 1297 | EXPECT_EQ(149, env->GetArrayLength(reinterpret_cast<jarray>(o149))); |
| 1298 | EXPECT_EQ(150, env->GetArrayLength(reinterpret_cast<jarray>(o150))); |
| 1299 | EXPECT_EQ(151, env->GetArrayLength(reinterpret_cast<jarray>(o151))); |
| 1300 | EXPECT_EQ(152, env->GetArrayLength(reinterpret_cast<jarray>(o152))); |
| 1301 | EXPECT_EQ(153, env->GetArrayLength(reinterpret_cast<jarray>(o153))); |
| 1302 | EXPECT_EQ(154, env->GetArrayLength(reinterpret_cast<jarray>(o154))); |
| 1303 | EXPECT_EQ(155, env->GetArrayLength(reinterpret_cast<jarray>(o155))); |
| 1304 | EXPECT_EQ(156, env->GetArrayLength(reinterpret_cast<jarray>(o156))); |
| 1305 | EXPECT_EQ(157, env->GetArrayLength(reinterpret_cast<jarray>(o157))); |
| 1306 | EXPECT_EQ(158, env->GetArrayLength(reinterpret_cast<jarray>(o158))); |
| 1307 | EXPECT_EQ(159, env->GetArrayLength(reinterpret_cast<jarray>(o159))); |
| 1308 | EXPECT_EQ(160, env->GetArrayLength(reinterpret_cast<jarray>(o160))); |
| 1309 | EXPECT_EQ(161, env->GetArrayLength(reinterpret_cast<jarray>(o161))); |
| 1310 | EXPECT_EQ(162, env->GetArrayLength(reinterpret_cast<jarray>(o162))); |
| 1311 | EXPECT_EQ(163, env->GetArrayLength(reinterpret_cast<jarray>(o163))); |
| 1312 | EXPECT_EQ(164, env->GetArrayLength(reinterpret_cast<jarray>(o164))); |
| 1313 | EXPECT_EQ(165, env->GetArrayLength(reinterpret_cast<jarray>(o165))); |
| 1314 | EXPECT_EQ(166, env->GetArrayLength(reinterpret_cast<jarray>(o166))); |
| 1315 | EXPECT_EQ(167, env->GetArrayLength(reinterpret_cast<jarray>(o167))); |
| 1316 | EXPECT_EQ(168, env->GetArrayLength(reinterpret_cast<jarray>(o168))); |
| 1317 | EXPECT_EQ(169, env->GetArrayLength(reinterpret_cast<jarray>(o169))); |
| 1318 | EXPECT_EQ(170, env->GetArrayLength(reinterpret_cast<jarray>(o170))); |
| 1319 | EXPECT_EQ(171, env->GetArrayLength(reinterpret_cast<jarray>(o171))); |
| 1320 | EXPECT_EQ(172, env->GetArrayLength(reinterpret_cast<jarray>(o172))); |
| 1321 | EXPECT_EQ(173, env->GetArrayLength(reinterpret_cast<jarray>(o173))); |
| 1322 | EXPECT_EQ(174, env->GetArrayLength(reinterpret_cast<jarray>(o174))); |
| 1323 | EXPECT_EQ(175, env->GetArrayLength(reinterpret_cast<jarray>(o175))); |
| 1324 | EXPECT_EQ(176, env->GetArrayLength(reinterpret_cast<jarray>(o176))); |
| 1325 | EXPECT_EQ(177, env->GetArrayLength(reinterpret_cast<jarray>(o177))); |
| 1326 | EXPECT_EQ(178, env->GetArrayLength(reinterpret_cast<jarray>(o178))); |
| 1327 | EXPECT_EQ(179, env->GetArrayLength(reinterpret_cast<jarray>(o179))); |
| 1328 | EXPECT_EQ(180, env->GetArrayLength(reinterpret_cast<jarray>(o180))); |
| 1329 | EXPECT_EQ(181, env->GetArrayLength(reinterpret_cast<jarray>(o181))); |
| 1330 | EXPECT_EQ(182, env->GetArrayLength(reinterpret_cast<jarray>(o182))); |
| 1331 | EXPECT_EQ(183, env->GetArrayLength(reinterpret_cast<jarray>(o183))); |
| 1332 | EXPECT_EQ(184, env->GetArrayLength(reinterpret_cast<jarray>(o184))); |
| 1333 | EXPECT_EQ(185, env->GetArrayLength(reinterpret_cast<jarray>(o185))); |
| 1334 | EXPECT_EQ(186, env->GetArrayLength(reinterpret_cast<jarray>(o186))); |
| 1335 | EXPECT_EQ(187, env->GetArrayLength(reinterpret_cast<jarray>(o187))); |
| 1336 | EXPECT_EQ(188, env->GetArrayLength(reinterpret_cast<jarray>(o188))); |
| 1337 | EXPECT_EQ(189, env->GetArrayLength(reinterpret_cast<jarray>(o189))); |
| 1338 | EXPECT_EQ(190, env->GetArrayLength(reinterpret_cast<jarray>(o190))); |
| 1339 | EXPECT_EQ(191, env->GetArrayLength(reinterpret_cast<jarray>(o191))); |
| 1340 | EXPECT_EQ(192, env->GetArrayLength(reinterpret_cast<jarray>(o192))); |
| 1341 | EXPECT_EQ(193, env->GetArrayLength(reinterpret_cast<jarray>(o193))); |
| 1342 | EXPECT_EQ(194, env->GetArrayLength(reinterpret_cast<jarray>(o194))); |
| 1343 | EXPECT_EQ(195, env->GetArrayLength(reinterpret_cast<jarray>(o195))); |
| 1344 | EXPECT_EQ(196, env->GetArrayLength(reinterpret_cast<jarray>(o196))); |
| 1345 | EXPECT_EQ(197, env->GetArrayLength(reinterpret_cast<jarray>(o197))); |
| 1346 | EXPECT_EQ(198, env->GetArrayLength(reinterpret_cast<jarray>(o198))); |
| 1347 | EXPECT_EQ(199, env->GetArrayLength(reinterpret_cast<jarray>(o199))); |
| 1348 | EXPECT_EQ(200, env->GetArrayLength(reinterpret_cast<jarray>(o200))); |
| 1349 | EXPECT_EQ(201, env->GetArrayLength(reinterpret_cast<jarray>(o201))); |
| 1350 | EXPECT_EQ(202, env->GetArrayLength(reinterpret_cast<jarray>(o202))); |
| 1351 | EXPECT_EQ(203, env->GetArrayLength(reinterpret_cast<jarray>(o203))); |
| 1352 | EXPECT_EQ(204, env->GetArrayLength(reinterpret_cast<jarray>(o204))); |
| 1353 | EXPECT_EQ(205, env->GetArrayLength(reinterpret_cast<jarray>(o205))); |
| 1354 | EXPECT_EQ(206, env->GetArrayLength(reinterpret_cast<jarray>(o206))); |
| 1355 | EXPECT_EQ(207, env->GetArrayLength(reinterpret_cast<jarray>(o207))); |
| 1356 | EXPECT_EQ(208, env->GetArrayLength(reinterpret_cast<jarray>(o208))); |
| 1357 | EXPECT_EQ(209, env->GetArrayLength(reinterpret_cast<jarray>(o209))); |
| 1358 | EXPECT_EQ(210, env->GetArrayLength(reinterpret_cast<jarray>(o210))); |
| 1359 | EXPECT_EQ(211, env->GetArrayLength(reinterpret_cast<jarray>(o211))); |
| 1360 | EXPECT_EQ(212, env->GetArrayLength(reinterpret_cast<jarray>(o212))); |
| 1361 | EXPECT_EQ(213, env->GetArrayLength(reinterpret_cast<jarray>(o213))); |
| 1362 | EXPECT_EQ(214, env->GetArrayLength(reinterpret_cast<jarray>(o214))); |
| 1363 | EXPECT_EQ(215, env->GetArrayLength(reinterpret_cast<jarray>(o215))); |
| 1364 | EXPECT_EQ(216, env->GetArrayLength(reinterpret_cast<jarray>(o216))); |
| 1365 | EXPECT_EQ(217, env->GetArrayLength(reinterpret_cast<jarray>(o217))); |
| 1366 | EXPECT_EQ(218, env->GetArrayLength(reinterpret_cast<jarray>(o218))); |
| 1367 | EXPECT_EQ(219, env->GetArrayLength(reinterpret_cast<jarray>(o219))); |
| 1368 | EXPECT_EQ(220, env->GetArrayLength(reinterpret_cast<jarray>(o220))); |
| 1369 | EXPECT_EQ(221, env->GetArrayLength(reinterpret_cast<jarray>(o221))); |
| 1370 | EXPECT_EQ(222, env->GetArrayLength(reinterpret_cast<jarray>(o222))); |
| 1371 | EXPECT_EQ(223, env->GetArrayLength(reinterpret_cast<jarray>(o223))); |
| 1372 | EXPECT_EQ(224, env->GetArrayLength(reinterpret_cast<jarray>(o224))); |
| 1373 | EXPECT_EQ(225, env->GetArrayLength(reinterpret_cast<jarray>(o225))); |
| 1374 | EXPECT_EQ(226, env->GetArrayLength(reinterpret_cast<jarray>(o226))); |
| 1375 | EXPECT_EQ(227, env->GetArrayLength(reinterpret_cast<jarray>(o227))); |
| 1376 | EXPECT_EQ(228, env->GetArrayLength(reinterpret_cast<jarray>(o228))); |
| 1377 | EXPECT_EQ(229, env->GetArrayLength(reinterpret_cast<jarray>(o229))); |
| 1378 | EXPECT_EQ(230, env->GetArrayLength(reinterpret_cast<jarray>(o230))); |
| 1379 | EXPECT_EQ(231, env->GetArrayLength(reinterpret_cast<jarray>(o231))); |
| 1380 | EXPECT_EQ(232, env->GetArrayLength(reinterpret_cast<jarray>(o232))); |
| 1381 | EXPECT_EQ(233, env->GetArrayLength(reinterpret_cast<jarray>(o233))); |
| 1382 | EXPECT_EQ(234, env->GetArrayLength(reinterpret_cast<jarray>(o234))); |
| 1383 | EXPECT_EQ(235, env->GetArrayLength(reinterpret_cast<jarray>(o235))); |
| 1384 | EXPECT_EQ(236, env->GetArrayLength(reinterpret_cast<jarray>(o236))); |
| 1385 | EXPECT_EQ(237, env->GetArrayLength(reinterpret_cast<jarray>(o237))); |
| 1386 | EXPECT_EQ(238, env->GetArrayLength(reinterpret_cast<jarray>(o238))); |
| 1387 | EXPECT_EQ(239, env->GetArrayLength(reinterpret_cast<jarray>(o239))); |
| 1388 | EXPECT_EQ(240, env->GetArrayLength(reinterpret_cast<jarray>(o240))); |
| 1389 | EXPECT_EQ(241, env->GetArrayLength(reinterpret_cast<jarray>(o241))); |
| 1390 | EXPECT_EQ(242, env->GetArrayLength(reinterpret_cast<jarray>(o242))); |
| 1391 | EXPECT_EQ(243, env->GetArrayLength(reinterpret_cast<jarray>(o243))); |
| 1392 | EXPECT_EQ(244, env->GetArrayLength(reinterpret_cast<jarray>(o244))); |
| 1393 | EXPECT_EQ(245, env->GetArrayLength(reinterpret_cast<jarray>(o245))); |
| 1394 | EXPECT_EQ(246, env->GetArrayLength(reinterpret_cast<jarray>(o246))); |
| 1395 | EXPECT_EQ(247, env->GetArrayLength(reinterpret_cast<jarray>(o247))); |
| 1396 | EXPECT_EQ(248, env->GetArrayLength(reinterpret_cast<jarray>(o248))); |
| 1397 | EXPECT_EQ(249, env->GetArrayLength(reinterpret_cast<jarray>(o249))); |
| 1398 | EXPECT_EQ(250, env->GetArrayLength(reinterpret_cast<jarray>(o250))); |
| 1399 | EXPECT_EQ(251, env->GetArrayLength(reinterpret_cast<jarray>(o251))); |
| 1400 | EXPECT_EQ(252, env->GetArrayLength(reinterpret_cast<jarray>(o252))); |
| 1401 | EXPECT_EQ(253, env->GetArrayLength(reinterpret_cast<jarray>(o253))); |
| 1402 | } |
| 1403 | } |
| 1404 | |
| 1405 | const char* longSig = |
| 1406 | "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1407 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1408 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1409 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1410 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1411 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1412 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1413 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1414 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1415 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1416 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1417 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1418 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1419 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1420 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1421 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1422 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1423 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1424 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1425 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1426 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1427 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1428 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1429 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1430 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1431 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1432 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1433 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1434 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1435 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1436 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1437 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1438 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1439 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1440 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1441 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1442 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1443 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1444 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1445 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1446 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1447 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1448 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1449 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1450 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1451 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1452 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1453 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1454 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1455 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;" |
| 1456 | "Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V"; |
| 1457 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1458 | void JniCompilerTest::MaxParamNumberImpl() { |
Andreas Gampe | 7a0e504 | 2014-03-07 13:03:19 -0800 | [diff] [blame] | 1459 | SetUpForTest(false, "maxParamNumber", longSig, |
| 1460 | reinterpret_cast<void*>(&Java_MyClassNatives_maxParamNumber)); |
| 1461 | |
| 1462 | jvalue args[254]; |
| 1463 | |
| 1464 | // First test: test with all arguments null. |
| 1465 | for (int i = 0; i < 254; ++i) { |
| 1466 | args[i].l = nullptr; |
| 1467 | } |
| 1468 | |
| 1469 | env_->CallNonvirtualVoidMethodA(jobj_, jklass_, jmethod_, args); |
| 1470 | |
| 1471 | // Second test: test with int[] objects with increasing lengths |
| 1472 | for (int i = 0; i < 254; ++i) { |
| 1473 | jintArray tmp = env_->NewIntArray(i); |
| 1474 | args[i].l = tmp; |
| 1475 | EXPECT_NE(args[i].l, nullptr); |
| 1476 | } |
| 1477 | |
| 1478 | env_->CallNonvirtualVoidMethodA(jobj_, jklass_, jmethod_, args); |
| 1479 | } |
| 1480 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1481 | JNI_TEST(MaxParamNumber) |
| 1482 | |
| 1483 | void JniCompilerTest::WithoutImplementationImpl() { |
Andreas Gampe | 369810a | 2015-01-14 19:53:31 -0800 | [diff] [blame] | 1484 | // This will lead to error messages in the log. |
| 1485 | ScopedLogSeverity sls(LogSeverity::FATAL); |
| 1486 | |
Andreas Gampe | ad61517 | 2014-04-04 16:20:13 -0700 | [diff] [blame] | 1487 | SetUpForTest(false, "withoutImplementation", "()V", nullptr); |
| 1488 | |
| 1489 | env_->CallVoidMethod(jobj_, jmethod_); |
| 1490 | |
| 1491 | EXPECT_TRUE(Thread::Current()->IsExceptionPending()); |
| 1492 | EXPECT_TRUE(env_->ExceptionCheck() == JNI_TRUE); |
| 1493 | } |
| 1494 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1495 | JNI_TEST(WithoutImplementation) |
| 1496 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 1497 | void Java_MyClassNatives_stackArgsIntsFirst(JNIEnv*, jclass, jint i1, jint i2, jint i3, |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1498 | jint i4, jint i5, jint i6, jint i7, jint i8, jint i9, |
| 1499 | jint i10, jfloat f1, jfloat f2, jfloat f3, jfloat f4, |
| 1500 | jfloat f5, jfloat f6, jfloat f7, jfloat f8, jfloat f9, |
| 1501 | jfloat f10) { |
| 1502 | EXPECT_EQ(i1, 1); |
| 1503 | EXPECT_EQ(i2, 2); |
| 1504 | EXPECT_EQ(i3, 3); |
| 1505 | EXPECT_EQ(i4, 4); |
| 1506 | EXPECT_EQ(i5, 5); |
| 1507 | EXPECT_EQ(i6, 6); |
| 1508 | EXPECT_EQ(i7, 7); |
| 1509 | EXPECT_EQ(i8, 8); |
| 1510 | EXPECT_EQ(i9, 9); |
| 1511 | EXPECT_EQ(i10, 10); |
| 1512 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1513 | jint i11 = bit_cast<jfloat, jint>(f1); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1514 | EXPECT_EQ(i11, 11); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1515 | jint i12 = bit_cast<jfloat, jint>(f2); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1516 | EXPECT_EQ(i12, 12); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1517 | jint i13 = bit_cast<jfloat, jint>(f3); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1518 | EXPECT_EQ(i13, 13); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1519 | jint i14 = bit_cast<jfloat, jint>(f4); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1520 | EXPECT_EQ(i14, 14); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1521 | jint i15 = bit_cast<jfloat, jint>(f5); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1522 | EXPECT_EQ(i15, 15); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1523 | jint i16 = bit_cast<jfloat, jint>(f6); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1524 | EXPECT_EQ(i16, 16); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1525 | jint i17 = bit_cast<jfloat, jint>(f7); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1526 | EXPECT_EQ(i17, 17); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1527 | jint i18 = bit_cast<jfloat, jint>(f8); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1528 | EXPECT_EQ(i18, 18); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1529 | jint i19 = bit_cast<jfloat, jint>(f9); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1530 | EXPECT_EQ(i19, 19); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1531 | jint i20 = bit_cast<jfloat, jint>(f10); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1532 | EXPECT_EQ(i20, 20); |
| 1533 | } |
| 1534 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1535 | void JniCompilerTest::StackArgsIntsFirstImpl() { |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1536 | SetUpForTest(true, "stackArgsIntsFirst", "(IIIIIIIIIIFFFFFFFFFF)V", |
| 1537 | reinterpret_cast<void*>(&Java_MyClassNatives_stackArgsIntsFirst)); |
| 1538 | |
| 1539 | jint i1 = 1; |
| 1540 | jint i2 = 2; |
| 1541 | jint i3 = 3; |
| 1542 | jint i4 = 4; |
| 1543 | jint i5 = 5; |
| 1544 | jint i6 = 6; |
| 1545 | jint i7 = 7; |
| 1546 | jint i8 = 8; |
| 1547 | jint i9 = 9; |
| 1548 | jint i10 = 10; |
| 1549 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1550 | jfloat f1 = bit_cast<jint, jfloat>(11); |
| 1551 | jfloat f2 = bit_cast<jint, jfloat>(12); |
| 1552 | jfloat f3 = bit_cast<jint, jfloat>(13); |
| 1553 | jfloat f4 = bit_cast<jint, jfloat>(14); |
| 1554 | jfloat f5 = bit_cast<jint, jfloat>(15); |
| 1555 | jfloat f6 = bit_cast<jint, jfloat>(16); |
| 1556 | jfloat f7 = bit_cast<jint, jfloat>(17); |
| 1557 | jfloat f8 = bit_cast<jint, jfloat>(18); |
| 1558 | jfloat f9 = bit_cast<jint, jfloat>(19); |
| 1559 | jfloat f10 = bit_cast<jint, jfloat>(20); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1560 | |
| 1561 | env_->CallStaticVoidMethod(jklass_, jmethod_, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, f1, f2, |
| 1562 | f3, f4, f5, f6, f7, f8, f9, f10); |
| 1563 | } |
| 1564 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1565 | JNI_TEST(StackArgsIntsFirst) |
| 1566 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 1567 | void Java_MyClassNatives_stackArgsFloatsFirst(JNIEnv*, jclass, jfloat f1, jfloat f2, |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1568 | jfloat f3, jfloat f4, jfloat f5, jfloat f6, jfloat f7, |
| 1569 | jfloat f8, jfloat f9, jfloat f10, jint i1, jint i2, |
| 1570 | jint i3, jint i4, jint i5, jint i6, jint i7, jint i8, |
| 1571 | jint i9, jint i10) { |
| 1572 | EXPECT_EQ(i1, 1); |
| 1573 | EXPECT_EQ(i2, 2); |
| 1574 | EXPECT_EQ(i3, 3); |
| 1575 | EXPECT_EQ(i4, 4); |
| 1576 | EXPECT_EQ(i5, 5); |
| 1577 | EXPECT_EQ(i6, 6); |
| 1578 | EXPECT_EQ(i7, 7); |
| 1579 | EXPECT_EQ(i8, 8); |
| 1580 | EXPECT_EQ(i9, 9); |
| 1581 | EXPECT_EQ(i10, 10); |
| 1582 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1583 | jint i11 = bit_cast<jfloat, jint>(f1); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1584 | EXPECT_EQ(i11, 11); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1585 | jint i12 = bit_cast<jfloat, jint>(f2); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1586 | EXPECT_EQ(i12, 12); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1587 | jint i13 = bit_cast<jfloat, jint>(f3); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1588 | EXPECT_EQ(i13, 13); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1589 | jint i14 = bit_cast<jfloat, jint>(f4); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1590 | EXPECT_EQ(i14, 14); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1591 | jint i15 = bit_cast<jfloat, jint>(f5); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1592 | EXPECT_EQ(i15, 15); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1593 | jint i16 = bit_cast<jfloat, jint>(f6); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1594 | EXPECT_EQ(i16, 16); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1595 | jint i17 = bit_cast<jfloat, jint>(f7); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1596 | EXPECT_EQ(i17, 17); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1597 | jint i18 = bit_cast<jfloat, jint>(f8); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1598 | EXPECT_EQ(i18, 18); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1599 | jint i19 = bit_cast<jfloat, jint>(f9); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1600 | EXPECT_EQ(i19, 19); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1601 | jint i20 = bit_cast<jfloat, jint>(f10); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1602 | EXPECT_EQ(i20, 20); |
| 1603 | } |
| 1604 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1605 | void JniCompilerTest::StackArgsFloatsFirstImpl() { |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1606 | SetUpForTest(true, "stackArgsFloatsFirst", "(FFFFFFFFFFIIIIIIIIII)V", |
| 1607 | reinterpret_cast<void*>(&Java_MyClassNatives_stackArgsFloatsFirst)); |
| 1608 | |
| 1609 | jint i1 = 1; |
| 1610 | jint i2 = 2; |
| 1611 | jint i3 = 3; |
| 1612 | jint i4 = 4; |
| 1613 | jint i5 = 5; |
| 1614 | jint i6 = 6; |
| 1615 | jint i7 = 7; |
| 1616 | jint i8 = 8; |
| 1617 | jint i9 = 9; |
| 1618 | jint i10 = 10; |
| 1619 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1620 | jfloat f1 = bit_cast<jint, jfloat>(11); |
| 1621 | jfloat f2 = bit_cast<jint, jfloat>(12); |
| 1622 | jfloat f3 = bit_cast<jint, jfloat>(13); |
| 1623 | jfloat f4 = bit_cast<jint, jfloat>(14); |
| 1624 | jfloat f5 = bit_cast<jint, jfloat>(15); |
| 1625 | jfloat f6 = bit_cast<jint, jfloat>(16); |
| 1626 | jfloat f7 = bit_cast<jint, jfloat>(17); |
| 1627 | jfloat f8 = bit_cast<jint, jfloat>(18); |
| 1628 | jfloat f9 = bit_cast<jint, jfloat>(19); |
| 1629 | jfloat f10 = bit_cast<jint, jfloat>(20); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1630 | |
| 1631 | env_->CallStaticVoidMethod(jklass_, jmethod_, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, i1, i2, i3, |
| 1632 | i4, i5, i6, i7, i8, i9, i10); |
| 1633 | } |
| 1634 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1635 | JNI_TEST(StackArgsFloatsFirst) |
| 1636 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 1637 | void Java_MyClassNatives_stackArgsMixed(JNIEnv*, jclass, jint i1, jfloat f1, jint i2, |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1638 | jfloat f2, jint i3, jfloat f3, jint i4, jfloat f4, jint i5, |
| 1639 | jfloat f5, jint i6, jfloat f6, jint i7, jfloat f7, jint i8, |
| 1640 | jfloat f8, jint i9, jfloat f9, jint i10, jfloat f10) { |
| 1641 | EXPECT_EQ(i1, 1); |
| 1642 | EXPECT_EQ(i2, 2); |
| 1643 | EXPECT_EQ(i3, 3); |
| 1644 | EXPECT_EQ(i4, 4); |
| 1645 | EXPECT_EQ(i5, 5); |
| 1646 | EXPECT_EQ(i6, 6); |
| 1647 | EXPECT_EQ(i7, 7); |
| 1648 | EXPECT_EQ(i8, 8); |
| 1649 | EXPECT_EQ(i9, 9); |
| 1650 | EXPECT_EQ(i10, 10); |
| 1651 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1652 | jint i11 = bit_cast<jfloat, jint>(f1); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1653 | EXPECT_EQ(i11, 11); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1654 | jint i12 = bit_cast<jfloat, jint>(f2); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1655 | EXPECT_EQ(i12, 12); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1656 | jint i13 = bit_cast<jfloat, jint>(f3); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1657 | EXPECT_EQ(i13, 13); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1658 | jint i14 = bit_cast<jfloat, jint>(f4); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1659 | EXPECT_EQ(i14, 14); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1660 | jint i15 = bit_cast<jfloat, jint>(f5); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1661 | EXPECT_EQ(i15, 15); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1662 | jint i16 = bit_cast<jfloat, jint>(f6); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1663 | EXPECT_EQ(i16, 16); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1664 | jint i17 = bit_cast<jfloat, jint>(f7); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1665 | EXPECT_EQ(i17, 17); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1666 | jint i18 = bit_cast<jfloat, jint>(f8); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1667 | EXPECT_EQ(i18, 18); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1668 | jint i19 = bit_cast<jfloat, jint>(f9); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1669 | EXPECT_EQ(i19, 19); |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1670 | jint i20 = bit_cast<jfloat, jint>(f10); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1671 | EXPECT_EQ(i20, 20); |
| 1672 | } |
| 1673 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1674 | void JniCompilerTest::StackArgsMixedImpl() { |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1675 | SetUpForTest(true, "stackArgsMixed", "(IFIFIFIFIFIFIFIFIFIF)V", |
| 1676 | reinterpret_cast<void*>(&Java_MyClassNatives_stackArgsMixed)); |
| 1677 | |
| 1678 | jint i1 = 1; |
| 1679 | jint i2 = 2; |
| 1680 | jint i3 = 3; |
| 1681 | jint i4 = 4; |
| 1682 | jint i5 = 5; |
| 1683 | jint i6 = 6; |
| 1684 | jint i7 = 7; |
| 1685 | jint i8 = 8; |
| 1686 | jint i9 = 9; |
| 1687 | jint i10 = 10; |
| 1688 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1689 | jfloat f1 = bit_cast<jint, jfloat>(11); |
| 1690 | jfloat f2 = bit_cast<jint, jfloat>(12); |
| 1691 | jfloat f3 = bit_cast<jint, jfloat>(13); |
| 1692 | jfloat f4 = bit_cast<jint, jfloat>(14); |
| 1693 | jfloat f5 = bit_cast<jint, jfloat>(15); |
| 1694 | jfloat f6 = bit_cast<jint, jfloat>(16); |
| 1695 | jfloat f7 = bit_cast<jint, jfloat>(17); |
| 1696 | jfloat f8 = bit_cast<jint, jfloat>(18); |
| 1697 | jfloat f9 = bit_cast<jint, jfloat>(19); |
| 1698 | jfloat f10 = bit_cast<jint, jfloat>(20); |
Vladimir Kostyukov | 1dd61ba | 2014-04-02 18:42:20 +0700 | [diff] [blame] | 1699 | |
| 1700 | env_->CallStaticVoidMethod(jklass_, jmethod_, i1, f1, i2, f2, i3, f3, i4, f4, i5, f5, i6, f6, i7, |
| 1701 | f7, i8, f8, i9, f9, i10, f10); |
| 1702 | } |
| 1703 | |
Andreas Gampe | 6e49869 | 2014-08-18 16:43:12 -0700 | [diff] [blame] | 1704 | JNI_TEST(StackArgsMixed) |
| 1705 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1706 | } // namespace art |