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