Lines Matching refs:env_
44 vm_->AttachCurrentThread(&env_, nullptr); in SetUp()
46 ScopedLocalRef<jclass> aioobe(env_, in SetUp()
47 env_->FindClass("java/lang/ArrayIndexOutOfBoundsException")); in SetUp()
49 aioobe_ = reinterpret_cast<jclass>(env_->NewGlobalRef(aioobe.get())); in SetUp()
51 ScopedLocalRef<jclass> ase(env_, env_->FindClass("java/lang/ArrayStoreException")); in SetUp()
53 ase_ = reinterpret_cast<jclass>(env_->NewGlobalRef(ase.get())); in SetUp()
55 ScopedLocalRef<jclass> sioobe(env_, in SetUp()
56 env_->FindClass("java/lang/StringIndexOutOfBoundsException")); in SetUp()
58 sioobe_ = reinterpret_cast<jclass>(env_->NewGlobalRef(sioobe.get())); in SetUp()
62 ScopedObjectAccess soa(env_); in ExpectException()
63 EXPECT_TRUE(env_->ExceptionCheck()) in ExpectException()
65 jthrowable exception = env_->ExceptionOccurred(); in ExpectException()
67 env_->ExceptionClear(); in ExpectException()
68 EXPECT_TRUE(env_->IsInstanceOf(exception, exception_class)); in ExpectException()
73 env_->DeleteGlobalRef(aioobe_); in CleanUpJniEnv()
77 env_->DeleteGlobalRef(ase_); in CleanUpJniEnv()
81 env_->DeleteGlobalRef(sioobe_); in CleanUpJniEnv()
92 ScopedObjectAccess soa(env_); in GetPrimitiveClass()
99 EXPECT_NE(env_->FindClass(name), nullptr) << name; in ExpectClassFound()
100 EXPECT_FALSE(env_->ExceptionCheck()) << name; in ExpectClassFound()
105 EXPECT_EQ(env_->FindClass(name), nullptr) << name; in ExpectClassNotFound()
107 EXPECT_TRUE(env_->ExceptionCheck()) << name; in ExpectClassNotFound()
108 env_->ExceptionClear(); in ExpectClassNotFound()
119 env_->FindClass(nullptr); in FindClassTest()
137 EXPECT_EQ(env_->FindClass("java.lang.String"), nullptr); in FindClassTest()
138 EXPECT_FALSE(env_->ExceptionCheck()); in FindClassTest()
141 EXPECT_EQ(env_->FindClass("[Ljava.lang.String;"), nullptr); in FindClassTest()
142 EXPECT_FALSE(env_->ExceptionCheck()); in FindClassTest()
175 jclass c = env_->FindClass("java/lang/String"); in GetFieldIdBadArgumentTest()
178 jfieldID fid = env_->GetFieldID(nullptr, "count", "I"); in GetFieldIdBadArgumentTest()
182 fid = env_->GetFieldID(c, nullptr, "I"); in GetFieldIdBadArgumentTest()
186 fid = env_->GetFieldID(c, "count", nullptr); in GetFieldIdBadArgumentTest()
198 jclass c = env_->FindClass("java/lang/String"); in GetStaticFieldIdBadArgumentTest()
201 …jfieldID fid = env_->GetStaticFieldID(nullptr, "CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); in GetStaticFieldIdBadArgumentTest()
205 fid = env_->GetStaticFieldID(c, nullptr, "Ljava/util/Comparator;"); in GetStaticFieldIdBadArgumentTest()
209 fid = env_->GetStaticFieldID(c, "CASE_INSENSITIVE_ORDER", nullptr); in GetStaticFieldIdBadArgumentTest()
221 jmethodID method = env_->GetMethodID(nullptr, "<init>", "(Ljava/lang/String;)V"); in GetMethodIdBadArgumentTest()
225 jclass jlnsme = env_->FindClass("java/lang/NoSuchMethodError"); in GetMethodIdBadArgumentTest()
227 method = env_->GetMethodID(jlnsme, nullptr, "(Ljava/lang/String;)V"); in GetMethodIdBadArgumentTest()
231 method = env_->GetMethodID(jlnsme, "<init>", nullptr); in GetMethodIdBadArgumentTest()
243 jmethodID method = env_->GetStaticMethodID(nullptr, "valueOf", "(I)Ljava/lang/String;"); in GetStaticMethodIdBadArgumentTest()
247 jclass jlstring = env_->FindClass("java/lang/String"); in GetStaticMethodIdBadArgumentTest()
248 method = env_->GetStaticMethodID(jlstring, nullptr, "(I)Ljava/lang/String;"); in GetStaticMethodIdBadArgumentTest()
252 method = env_->GetStaticMethodID(jlstring, "valueOf", nullptr); in GetStaticMethodIdBadArgumentTest()
264 jclass c = env_->FindClass("java/lang/String"); in GetFromReflectedField_ToReflectedFieldBadArgumentTest()
266 jfieldID fid = env_->GetFieldID(c, "count", "I"); in GetFromReflectedField_ToReflectedFieldBadArgumentTest()
270 jobject field = env_->ToReflectedField(nullptr, fid, JNI_FALSE); in GetFromReflectedField_ToReflectedFieldBadArgumentTest()
278 field = env_->ToReflectedField(c, nullptr, JNI_FALSE); in GetFromReflectedField_ToReflectedFieldBadArgumentTest()
283 fid = env_->FromReflectedField(nullptr); in GetFromReflectedField_ToReflectedFieldBadArgumentTest()
295 jclass c = env_->FindClass("java/lang/String"); in GetFromReflectedMethod_ToReflectedMethodBadArgumentTest()
297 jmethodID mid = env_->GetMethodID(c, "<init>", "()V"); in GetFromReflectedMethod_ToReflectedMethodBadArgumentTest()
301 jobject method = env_->ToReflectedMethod(nullptr, mid, JNI_FALSE); in GetFromReflectedMethod_ToReflectedMethodBadArgumentTest()
309 method = env_->ToReflectedMethod(c, nullptr, JNI_FALSE); in GetFromReflectedMethod_ToReflectedMethodBadArgumentTest()
313 mid = env_->FromReflectedMethod(method); in GetFromReflectedMethod_ToReflectedMethodBadArgumentTest()
326 EXPECT_EQ(env_->RegisterNatives(nullptr, methods, 0), JNI_ERR); in RegisterAndUnregisterNativesBadArguments()
332 jclass jlobject = env_->FindClass("java/lang/Object"); in RegisterAndUnregisterNativesBadArguments()
333 EXPECT_EQ(env_->RegisterNatives(jlobject, nullptr, 1), JNI_ERR); in RegisterAndUnregisterNativesBadArguments()
337 EXPECT_EQ(env_->UnregisterNatives(nullptr), JNI_ERR); in RegisterAndUnregisterNativesBadArguments()
349 jbooleanArray array = env_->NewBooleanArray(10); in GetPrimitiveArrayElementsOfWrongType()
351 EXPECT_EQ(env_->GetByteArrayElements(reinterpret_cast<jbyteArray>(array), &is_copy), nullptr); in GetPrimitiveArrayElementsOfWrongType()
355 EXPECT_EQ(env_->GetShortArrayElements(reinterpret_cast<jshortArray>(array), &is_copy), nullptr); in GetPrimitiveArrayElementsOfWrongType()
359 EXPECT_EQ(env_->GetCharArrayElements(reinterpret_cast<jcharArray>(array), &is_copy), nullptr); in GetPrimitiveArrayElementsOfWrongType()
363 EXPECT_EQ(env_->GetIntArrayElements(reinterpret_cast<jintArray>(array), &is_copy), nullptr); in GetPrimitiveArrayElementsOfWrongType()
367 EXPECT_EQ(env_->GetLongArrayElements(reinterpret_cast<jlongArray>(array), &is_copy), nullptr); in GetPrimitiveArrayElementsOfWrongType()
371 EXPECT_EQ(env_->GetFloatArrayElements(reinterpret_cast<jfloatArray>(array), &is_copy), nullptr); in GetPrimitiveArrayElementsOfWrongType()
375 … EXPECT_EQ(env_->GetDoubleArrayElements(reinterpret_cast<jdoubleArray>(array), &is_copy), nullptr); in GetPrimitiveArrayElementsOfWrongType()
379 jbyteArray array2 = env_->NewByteArray(10); in GetPrimitiveArrayElementsOfWrongType()
380 EXPECT_EQ(env_->GetBooleanArrayElements(reinterpret_cast<jbooleanArray>(array2), &is_copy), in GetPrimitiveArrayElementsOfWrongType()
385 jobject object = env_->NewStringUTF("Test String"); in GetPrimitiveArrayElementsOfWrongType()
386 EXPECT_EQ(env_->GetBooleanArrayElements(reinterpret_cast<jbooleanArray>(object), &is_copy), in GetPrimitiveArrayElementsOfWrongType()
399 jbooleanArray array = env_->NewBooleanArray(10); in ReleasePrimitiveArrayElementsOfWrongType()
402 jboolean* elements = env_->GetBooleanArrayElements(array, &is_copy); in ReleasePrimitiveArrayElementsOfWrongType()
404 env_->ReleaseByteArrayElements(reinterpret_cast<jbyteArray>(array), in ReleasePrimitiveArrayElementsOfWrongType()
409 env_->ReleaseShortArrayElements(reinterpret_cast<jshortArray>(array), in ReleasePrimitiveArrayElementsOfWrongType()
414 env_->ReleaseCharArrayElements(reinterpret_cast<jcharArray>(array), in ReleasePrimitiveArrayElementsOfWrongType()
419 env_->ReleaseIntArrayElements(reinterpret_cast<jintArray>(array), in ReleasePrimitiveArrayElementsOfWrongType()
424 env_->ReleaseLongArrayElements(reinterpret_cast<jlongArray>(array), in ReleasePrimitiveArrayElementsOfWrongType()
429 env_->ReleaseFloatArrayElements(reinterpret_cast<jfloatArray>(array), in ReleasePrimitiveArrayElementsOfWrongType()
434 env_->ReleaseDoubleArrayElements(reinterpret_cast<jdoubleArray>(array), in ReleasePrimitiveArrayElementsOfWrongType()
441 env_->ReleaseBooleanArrayElements(array, elements, 0); in ReleasePrimitiveArrayElementsOfWrongType()
444 jbyteArray array = env_->NewByteArray(10); in ReleasePrimitiveArrayElementsOfWrongType()
446 jbyte* elements = env_->GetByteArrayElements(array, &is_copy); in ReleasePrimitiveArrayElementsOfWrongType()
448 env_->ReleaseBooleanArrayElements(reinterpret_cast<jbooleanArray>(array), in ReleasePrimitiveArrayElementsOfWrongType()
453 jobject object = env_->NewStringUTF("Test String"); in ReleasePrimitiveArrayElementsOfWrongType()
454 env_->ReleaseBooleanArrayElements(reinterpret_cast<jbooleanArray>(object), in ReleasePrimitiveArrayElementsOfWrongType()
462 env_->ReleaseByteArrayElements(array, elements, 0); in ReleasePrimitiveArrayElementsOfWrongType()
471 jobject object = env_->NewStringUTF("Test String"); in GetReleasePrimitiveArrayCriticalOfWrongType()
473 void* elements = env_->GetPrimitiveArrayCritical(reinterpret_cast<jarray>(object), &is_copy); in GetReleasePrimitiveArrayCriticalOfWrongType()
476 env_->ReleasePrimitiveArrayCritical(reinterpret_cast<jarray>(object), elements, 0); in GetReleasePrimitiveArrayCriticalOfWrongType()
487 jbooleanArray array = env_->NewBooleanArray(kLength); in GetPrimitiveArrayRegionElementsOfWrongType()
490 env_->GetByteArrayRegion(reinterpret_cast<jbyteArray>(array), 0, kLength, in GetPrimitiveArrayRegionElementsOfWrongType()
495 env_->GetShortArrayRegion(reinterpret_cast<jshortArray>(array), 0, kLength, in GetPrimitiveArrayRegionElementsOfWrongType()
500 env_->GetCharArrayRegion(reinterpret_cast<jcharArray>(array), 0, kLength, in GetPrimitiveArrayRegionElementsOfWrongType()
505 env_->GetIntArrayRegion(reinterpret_cast<jintArray>(array), 0, kLength, in GetPrimitiveArrayRegionElementsOfWrongType()
510 env_->GetLongArrayRegion(reinterpret_cast<jlongArray>(array), 0, kLength, in GetPrimitiveArrayRegionElementsOfWrongType()
515 env_->GetFloatArrayRegion(reinterpret_cast<jfloatArray>(array), 0, kLength, in GetPrimitiveArrayRegionElementsOfWrongType()
520 env_->GetDoubleArrayRegion(reinterpret_cast<jdoubleArray>(array), 0, kLength, in GetPrimitiveArrayRegionElementsOfWrongType()
525 jbyteArray array2 = env_->NewByteArray(10); in GetPrimitiveArrayRegionElementsOfWrongType()
526 env_->GetBooleanArrayRegion(reinterpret_cast<jbooleanArray>(array2), 0, kLength, in GetPrimitiveArrayRegionElementsOfWrongType()
531 jobject object = env_->NewStringUTF("Test String"); in GetPrimitiveArrayRegionElementsOfWrongType()
532 env_->GetBooleanArrayRegion(reinterpret_cast<jbooleanArray>(object), 0, kLength, in GetPrimitiveArrayRegionElementsOfWrongType()
545 jbooleanArray array = env_->NewBooleanArray(kLength); in SetPrimitiveArrayRegionElementsOfWrongType()
548 env_->SetByteArrayRegion(reinterpret_cast<jbyteArray>(array), 0, kLength, in SetPrimitiveArrayRegionElementsOfWrongType()
553 env_->SetShortArrayRegion(reinterpret_cast<jshortArray>(array), 0, kLength, in SetPrimitiveArrayRegionElementsOfWrongType()
558 env_->SetCharArrayRegion(reinterpret_cast<jcharArray>(array), 0, kLength, in SetPrimitiveArrayRegionElementsOfWrongType()
563 env_->SetIntArrayRegion(reinterpret_cast<jintArray>(array), 0, kLength, in SetPrimitiveArrayRegionElementsOfWrongType()
568 env_->SetLongArrayRegion(reinterpret_cast<jlongArray>(array), 0, kLength, in SetPrimitiveArrayRegionElementsOfWrongType()
573 env_->SetFloatArrayRegion(reinterpret_cast<jfloatArray>(array), 0, kLength, in SetPrimitiveArrayRegionElementsOfWrongType()
578 env_->SetDoubleArrayRegion(reinterpret_cast<jdoubleArray>(array), 0, kLength, in SetPrimitiveArrayRegionElementsOfWrongType()
583 jbyteArray array2 = env_->NewByteArray(10); in SetPrimitiveArrayRegionElementsOfWrongType()
584 env_->SetBooleanArrayRegion(reinterpret_cast<jbooleanArray>(array2), 0, kLength, in SetPrimitiveArrayRegionElementsOfWrongType()
589 jobject object = env_->NewStringUTF("Test String"); in SetPrimitiveArrayRegionElementsOfWrongType()
590 env_->SetBooleanArrayRegion(reinterpret_cast<jbooleanArray>(object), 0, kLength, in SetPrimitiveArrayRegionElementsOfWrongType()
602 jclass element_class = env_->FindClass("java/lang/String"); in NewObjectArrayBadArguments()
605 env_->NewObjectArray(-1, element_class, nullptr); in NewObjectArrayBadArguments()
608 env_->NewObjectArray(std::numeric_limits<jint>::min(), element_class, nullptr); in NewObjectArrayBadArguments()
639 env_ = Thread::Current()->GetJniEnv(); in SetUpForTest()
640 jklass_ = env_->FindClass("MyClassNatives"); in SetUpForTest()
644 jmethod_ = env_->GetStaticMethodID(jklass_, method_name, method_sig); in SetUpForTest()
646 jmethod_ = env_->GetMethodID(jklass_, method_name, method_sig); in SetUpForTest()
652 ASSERT_EQ(JNI_OK, env_->RegisterNatives(jklass_, methods, 1)) in SetUpForTest()
655 env_->UnregisterNatives(jklass_); in SetUpForTest()
658 jmethodID constructor = env_->GetMethodID(jklass_, "<init>", "()V"); in SetUpForTest()
659 jobj_ = env_->NewObject(jklass_, constructor); in SetUpForTest()
664 JNIEnv* env_; member in art::JniInternalTest
676 jclass c = env_->FindClass("java/lang/String"); in TEST_F()
678 jobject o = env_->AllocObject(c); in TEST_F()
682 ASSERT_TRUE(env_->IsInstanceOf(o, c)); in TEST_F()
686 ASSERT_EQ(0, env_->GetIntField(o, env_->GetFieldID(c, "count", "I"))); in TEST_F()
690 ASSERT_EQ(JNI_VERSION_1_6, env_->GetVersion()); in TEST_F()
702 jclass jlnsfe = env_->FindClass("java/lang/NoSuchFieldError"); in TEST_F()
704 jclass c = env_->FindClass("java/lang/String"); in TEST_F()
708 jfieldID fid = env_->GetFieldID(c, "count", "J"); in TEST_F()
713 fid = env_->GetFieldID(c, "count", "Lrod/jane/freddy;"); in TEST_F()
718 fid = env_->GetFieldID(c, "Count", "I"); in TEST_F()
723 fid = env_->GetFieldID(c, "count", "I"); in TEST_F()
725 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
728 c = env_->FindClass("java/lang/StringBuilder"); in TEST_F()
729 fid = env_->GetFieldID(c, "count", "I"); in TEST_F()
732 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
735 fid = env_->GetFieldID(c, "CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); in TEST_F()
745 jclass jlnsfe = env_->FindClass("java/lang/NoSuchFieldError"); in TEST_F()
747 jclass c = env_->FindClass("java/lang/String"); in TEST_F()
751 jfieldID fid = env_->GetStaticFieldID(c, "CASE_INSENSITIVE_ORDER", "J"); in TEST_F()
756 fid = env_->GetStaticFieldID(c, "CASE_INSENSITIVE_ORDER", "Lrod/jane/freddy;"); in TEST_F()
761 fid = env_->GetStaticFieldID(c, "cASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); in TEST_F()
766 fid = env_->GetStaticFieldID(c, "CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); in TEST_F()
769 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
772 fid = env_->GetStaticFieldID(c, "count", "I"); in TEST_F()
782 jclass jlobject = env_->FindClass("java/lang/Object"); in TEST_F()
783 jclass jlstring = env_->FindClass("java/lang/String"); in TEST_F()
784 jclass jlnsme = env_->FindClass("java/lang/NoSuchMethodError"); in TEST_F()
785 jclass jncrbc = env_->FindClass("java/nio/channels/ReadableByteChannel"); in TEST_F()
788 ASSERT_FALSE(env_->ExceptionCheck()); in TEST_F()
792 jmethodID method = env_->GetMethodID(jlobject, "foo", "()V"); in TEST_F()
797 method = env_->GetMethodID(jlobject, "equals", "(Ljava/lang/Object;)Z"); in TEST_F()
799 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
803 method = env_->GetMethodID(jlstring, "valueOf", "(I)Ljava/lang/String;"); in TEST_F()
808 method = env_->GetMethodID(jlnsme, "<init>", "(Ljava/lang/String;)V"); in TEST_F()
810 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
813 method = env_->GetMethodID(jncrbc, "close", "()V"); in TEST_F()
815 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
823 jclass jlobject = env_->FindClass("java/lang/Object"); in TEST_F()
827 method = env_->GetMethodID(jlobject, "<init>", "()V"); in TEST_F()
829 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
833 env_->CallVoidMethod(nullptr, method); in TEST_F()
844 jclass prim_class = env_->FindClass("java/lang/" #boxed_type); \ in TEST_F()
845 jmethodID method = env_->GetStaticMethodID(prim_class, "valueOf", \ in TEST_F()
848 EXPECT_FALSE(env_->ExceptionCheck()); \ in TEST_F()
850 env_->CallStaticObjectMethod(prim_class, method, bad_value); \ in TEST_F()
871 jclass prim_class = env_->FindClass("java/lang/" #boxed_type); \ in TEST_F()
872 jmethodID method = env_->GetStaticMethodID(prim_class, "valueOf", \ in TEST_F()
875 EXPECT_FALSE(env_->ExceptionCheck()); \ in TEST_F()
879 env_->CallStaticObjectMethodA(prim_class, method, &jval); \ in TEST_F()
884 jclass prim_class = env_->FindClass("java/lang/" #boxed_type); \ in TEST_F()
885 jmethodID method = env_->GetStaticMethodID(prim_class, "valueOf", \ in TEST_F()
888 EXPECT_FALSE(env_->ExceptionCheck()); \ in TEST_F()
891 env_->CallStaticObjectMethodA(prim_class, method, &jval); \ in TEST_F()
905 jclass jlobject = env_->FindClass("java/lang/Object"); in TEST_F()
906 jclass jlnsme = env_->FindClass("java/lang/NoSuchMethodError"); in TEST_F()
909 ASSERT_FALSE(env_->ExceptionCheck()); in TEST_F()
913 jmethodID method = env_->GetStaticMethodID(jlobject, "foo", "()V"); in TEST_F()
919 method = env_->GetStaticMethodID(jlobject, "equals", "(Ljava/lang/Object;)Z"); in TEST_F()
924 jclass jlstring = env_->FindClass("java/lang/String"); in TEST_F()
925 method = env_->GetStaticMethodID(jlstring, "valueOf", "(I)Ljava/lang/String;"); in TEST_F()
927 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
940 jclass jlrField = env_->FindClass("java/lang/reflect/Field"); in TEST_F()
941 jclass c = env_->FindClass("java/lang/String"); in TEST_F()
943 jfieldID fid = env_->GetFieldID(c, "count", "I"); in TEST_F()
946 jobject field = env_->ToReflectedField(c, fid, JNI_FALSE); in TEST_F()
947 size_t capacity_before = GetLocalsCapacity(env_); in TEST_F()
951 env_->DeleteLocalRef(env_->ToReflectedField(c, fid, JNI_FALSE)); in TEST_F()
953 size_t capacity_after = GetLocalsCapacity(env_); in TEST_F()
957 ASSERT_TRUE(env_->IsInstanceOf(field, jlrField)); in TEST_F()
959 jfieldID fid2 = env_->FromReflectedField(field); in TEST_F()
962 jstring s = env_->NewStringUTF("poop"); in TEST_F()
965 env_->GetIntField(s, fid2)); in TEST_F()
967 jstring s_16 = env_->NewStringUTF("\u0444\u0444"); in TEST_F()
969 env_->GetIntField(s_16, fid2)); in TEST_F()
971 ASSERT_EQ(4, env_->GetIntField(s, fid2)); in TEST_F()
979 jclass jlrMethod = env_->FindClass("java/lang/reflect/Method"); in TEST_F()
981 jclass jlrConstructor = env_->FindClass("java/lang/reflect/Constructor"); in TEST_F()
983 jclass c = env_->FindClass("java/lang/String"); in TEST_F()
986 jmethodID mid = env_->GetMethodID(c, "<init>", "()V"); in TEST_F()
989 jobject method = env_->ToReflectedMethod(c, mid, JNI_FALSE); in TEST_F()
990 size_t capacity_before = GetLocalsCapacity(env_); in TEST_F()
994 env_->DeleteLocalRef(env_->ToReflectedMethod(c, mid, JNI_FALSE)); in TEST_F()
996 size_t capacity_after = GetLocalsCapacity(env_); in TEST_F()
999 ASSERT_TRUE(env_->IsInstanceOf(method, jlrConstructor)); in TEST_F()
1001 jmethodID mid2 = env_->FromReflectedMethod(method); in TEST_F()
1004 jstring s = reinterpret_cast<jstring>(env_->AllocObject(c)); in TEST_F()
1006 env_->CallVoidMethod(s, mid2); in TEST_F()
1007 ASSERT_EQ(JNI_FALSE, env_->ExceptionCheck()); in TEST_F()
1008 env_->ExceptionClear(); in TEST_F()
1010 mid = env_->GetMethodID(c, "length", "()I"); in TEST_F()
1013 method = env_->ToReflectedMethod(c, mid, JNI_FALSE); in TEST_F()
1015 ASSERT_TRUE(env_->IsInstanceOf(method, jlrMethod)); in TEST_F()
1017 mid2 = env_->FromReflectedMethod(method); in TEST_F()
1020 s = env_->NewStringUTF("poop"); in TEST_F()
1022 ASSERT_EQ(4, env_->CallIntMethod(s, mid2)); in TEST_F()
1034 jclass jlobject = env_->FindClass("java/lang/Object"); in TEST_F()
1035 jclass jlnsme = env_->FindClass("java/lang/NoSuchMethodError"); in TEST_F()
1039 ASSERT_FALSE(env_->ExceptionCheck()); in TEST_F()
1047 EXPECT_EQ(env_->RegisterNatives(jlobject, methods, 1), JNI_ERR); in TEST_F()
1054 EXPECT_EQ(env_->RegisterNatives(jlobject, methods, 1), JNI_ERR); in TEST_F()
1061 EXPECT_EQ(env_->RegisterNatives(jlobject, methods, 1), JNI_ERR); in TEST_F()
1068 EXPECT_EQ(env_->RegisterNatives(jlobject, methods, 1), JNI_ERR); in TEST_F()
1075 EXPECT_EQ(env_->RegisterNatives(jlobject, methods, 1), JNI_ERR); in TEST_F()
1083 EXPECT_EQ(env_->RegisterNatives(jlobject, methods, 1), JNI_OK); in TEST_F()
1085 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
1086 EXPECT_EQ(env_->UnregisterNatives(jlobject), JNI_OK); in TEST_F()
1091 EXPECT_EQ(env_->RegisterNatives(jlobject, methods, 0), JNI_OK); in TEST_F()
1093 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
1094 EXPECT_EQ(env_->UnregisterNatives(jlobject), JNI_OK); in TEST_F()
1100 EXPECT_EQ(env_->RegisterNatives(jlobject, methods, i), JNI_ERR); in TEST_F()
1103 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
1106 EXPECT_EQ(env_->UnregisterNatives(jlnsme), JNI_OK); in TEST_F()
1123 down_cast<JNIEnvExt*>(env_)->SetCheckJniEnabled(false); \
1125 EXPECT_EQ(env_->new_fn(-1), nullptr); \
1127 EXPECT_EQ(env_->new_fn(std::numeric_limits<jint>::min()), nullptr); \
1130 EXPECT_EQ(0, env_->GetArrayLength(nullptr)); \
1132 env_->get_region_fn(nullptr, 0, 0, nullptr); \
1134 env_->set_region_fn(nullptr, 0, 0, nullptr); \
1136 env_->get_elements_fn(nullptr, nullptr); \
1138 env_->release_elements_fn(nullptr, nullptr, 0); \
1141 scalar_type ## Array a = env_->new_fn(size); \
1142 env_->get_region_fn(a, 0, size, nullptr); \
1144 env_->set_region_fn(a, 0, size, nullptr); \
1146 down_cast<JNIEnvExt*>(env_)->SetCheckJniEnabled(true); \
1149 scalar_type ## Array a = env_->new_fn(size); \
1151 EXPECT_TRUE(env_->IsInstanceOf(a, env_->FindClass(expected_class_descriptor))); \
1152 EXPECT_EQ(size, env_->GetArrayLength(a)); \
1156 env_->get_region_fn(a, -1, 1, nullptr); \
1158 env_->set_region_fn(a, -1, 1, nullptr); \
1162 env_->get_region_fn(a, 0, -1, nullptr); \
1164 env_->set_region_fn(a, 0, -1, nullptr); \
1168 env_->get_region_fn(a, size - 1, size, nullptr); \
1170 env_->set_region_fn(a, size - 1, size, nullptr); \
1174 env_->get_region_fn(a, 0x7fffffff, 0x7fffffff, nullptr); \
1176 env_->set_region_fn(a, 0x7fffffff, 0x7fffffff, nullptr); \
1180 env_->get_region_fn(a, 2, 0, nullptr); \
1182 env_->get_region_fn(a, 123, 0, nullptr); \
1186 env_->set_region_fn(a, 2, 0, nullptr); \
1188 env_->set_region_fn(a, 123, 0, nullptr); \
1199 env_->set_region_fn(a, 0, size, &src_buf[0]); \
1201 env_->get_region_fn(a, 1, size - 2, &dst_buf[1]); \
1205 env_->get_region_fn(a, 0, 1, &dst_buf[0]); \
1206 env_->get_region_fn(a, size - 1, 1, &dst_buf[size - 1]); \
1210 env_->get_region_fn(a, 0, size, &dst_buf[0]); \
1214 void* v = env_->GetPrimitiveArrayCritical(a, nullptr); \
1217 env_->ReleasePrimitiveArrayCritical(a, v, 0); \
1219 scalar_type* xs = env_->get_elements_fn(a, nullptr); /* NOLINT, scalar_type */ \
1222 env_->release_elements_fn(a, xs, 0); \
1283 jclass element_class = env_->FindClass("java/lang/String"); in TEST_F()
1285 jclass array_class = env_->FindClass("[Ljava/lang/String;"); in TEST_F()
1288 jobjectArray a = env_->NewObjectArray(0, element_class, nullptr); in TEST_F()
1290 EXPECT_TRUE(env_->IsInstanceOf(a, array_class)); in TEST_F()
1291 EXPECT_EQ(0, env_->GetArrayLength(a)); in TEST_F()
1293 a = env_->NewObjectArray(1, element_class, nullptr); in TEST_F()
1295 EXPECT_TRUE(env_->IsInstanceOf(a, array_class)); in TEST_F()
1296 EXPECT_EQ(1, env_->GetArrayLength(a)); in TEST_F()
1297 EXPECT_TRUE(env_->IsSameObject(env_->GetObjectArrayElement(a, 0), nullptr)); in TEST_F()
1314 env_->NewObjectArray(0, nullptr, nullptr); in TEST_F()
1317 env_->NewObjectArray(1, primitive_class, nullptr); in TEST_F()
1323 env_->NewObjectArray(0, nullptr, nullptr); in TEST_F()
1326 env_->NewObjectArray(1, primitive_class, nullptr); in TEST_F()
1334 jclass element_class = env_->FindClass("java/lang/String"); in TEST_F()
1336 jclass array_class = env_->FindClass("[Ljava/lang/String;"); in TEST_F()
1339 jstring s = env_->NewStringUTF("poop"); in TEST_F()
1340 jobjectArray a = env_->NewObjectArray(2, element_class, s); in TEST_F()
1342 EXPECT_TRUE(env_->IsInstanceOf(a, array_class)); in TEST_F()
1343 EXPECT_EQ(2, env_->GetArrayLength(a)); in TEST_F()
1344 EXPECT_TRUE(env_->IsSameObject(env_->GetObjectArrayElement(a, 0), s)); in TEST_F()
1345 EXPECT_TRUE(env_->IsSameObject(env_->GetObjectArrayElement(a, 1), s)); in TEST_F()
1349 env_->NewObjectArray(2, element_class, a); in TEST_F()
1358 EXPECT_EQ(0, env_->GetArrayLength(nullptr)); in TEST_F()
1361 EXPECT_EQ(JNI_ERR, env_->GetArrayLength(nullptr)); in TEST_F()
1367 jclass string_class = env_->FindClass("java/lang/String"); in TEST_F()
1369 jclass class_class = env_->FindClass("java/lang/Class"); in TEST_F()
1372 jstring s = env_->NewStringUTF("poop"); in TEST_F()
1373 jclass c = env_->GetObjectClass(s); in TEST_F()
1374 ASSERT_TRUE(env_->IsSameObject(string_class, c)); in TEST_F()
1376 jclass c2 = env_->GetObjectClass(c); in TEST_F()
1377 ASSERT_TRUE(env_->IsSameObject(class_class, env_->GetObjectClass(c2))); in TEST_F()
1381 EXPECT_EQ(env_->GetObjectClass(nullptr), nullptr); in TEST_F()
1386 jclass object_class = env_->FindClass("java/lang/Object"); in TEST_F()
1388 jclass string_class = env_->FindClass("java/lang/String"); in TEST_F()
1390 jclass runnable_interface = env_->FindClass("java/lang/Runnable"); in TEST_F()
1392 ASSERT_TRUE(env_->IsSameObject(object_class, env_->GetSuperclass(string_class))); in TEST_F()
1393 ASSERT_EQ(env_->GetSuperclass(object_class), nullptr); in TEST_F()
1394 ASSERT_EQ(env_->GetSuperclass(runnable_interface), nullptr); in TEST_F()
1399 EXPECT_EQ(env_->GetSuperclass(nullptr), nullptr); in TEST_F()
1402 EXPECT_EQ(env_->GetSuperclass(nullptr), nullptr); in TEST_F()
1408 jclass object_class = env_->FindClass("java/lang/Object"); in TEST_F()
1410 jclass string_class = env_->FindClass("java/lang/String"); in TEST_F()
1415 ASSERT_TRUE(env_->IsAssignableFrom(string_class, object_class)); in TEST_F()
1416 ASSERT_FALSE(env_->IsAssignableFrom(object_class, string_class)); in TEST_F()
1418 jclass charsequence_interface = env_->FindClass("java/lang/CharSequence"); in TEST_F()
1423 ASSERT_TRUE(env_->IsAssignableFrom(string_class, charsequence_interface)); in TEST_F()
1424 ASSERT_FALSE(env_->IsAssignableFrom(charsequence_interface, string_class)); in TEST_F()
1427 jclass string_array_class = env_->FindClass("[Ljava/lang/String;"); in TEST_F()
1429 jclass object_array_class = env_->FindClass("[Ljava/lang/Object;"); in TEST_F()
1431 ASSERT_TRUE(env_->IsAssignableFrom(string_array_class, object_array_class)); in TEST_F()
1432 ASSERT_FALSE(env_->IsAssignableFrom(object_array_class, string_array_class)); in TEST_F()
1439 EXPECT_EQ(env_->IsAssignableFrom(nullptr, string_class), JNI_FALSE); in TEST_F()
1441 EXPECT_EQ(env_->IsAssignableFrom(object_class, nullptr), JNI_FALSE); in TEST_F()
1444 EXPECT_EQ(env_->IsAssignableFrom(nullptr, string_class), JNI_FALSE); in TEST_F()
1446 EXPECT_EQ(env_->IsAssignableFrom(object_class, nullptr), JNI_FALSE); in TEST_F()
1452 jclass local = env_->FindClass("java/lang/Object"); in TEST_F()
1454 EXPECT_EQ(JNILocalRefType, env_->GetObjectRefType(local)); in TEST_F()
1456 jobject global = env_->NewGlobalRef(local); in TEST_F()
1457 EXPECT_EQ(JNIGlobalRefType, env_->GetObjectRefType(global)); in TEST_F()
1459 jweak weak_global = env_->NewWeakGlobalRef(local); in TEST_F()
1460 EXPECT_EQ(JNIWeakGlobalRefType, env_->GetObjectRefType(weak_global)); in TEST_F()
1465 EXPECT_EQ(JNIInvalidRefType, env_->GetObjectRefType(invalid)); in TEST_F()
1472 EXPECT_EQ(JNIInvalidRefType, env_->GetObjectRefType(nullptr)); in TEST_F()
1479 jclass java_lang_Class = env_->FindClass("java/lang/Class"); in TEST_F()
1481 jobjectArray local_ref = env_->NewObjectArray(1, java_lang_Class, nullptr); in TEST_F()
1483 jweak weak_global = env_->NewWeakGlobalRef(local_ref); in TEST_F()
1485 env_->DeleteLocalRef(local_ref); in TEST_F()
1488 jobject new_global_ref = env_->NewGlobalRef(weak_global); in TEST_F()
1490 jobject new_local_ref = env_->NewLocalRef(weak_global); in TEST_F()
1495 EXPECT_EQ(env_->NewStringUTF(nullptr), nullptr); in TEST_F()
1498 s = env_->NewStringUTF(""); in TEST_F()
1500 EXPECT_EQ(0, env_->GetStringLength(s)); in TEST_F()
1501 EXPECT_EQ(0, env_->GetStringUTFLength(s)); in TEST_F()
1502 s = env_->NewStringUTF("hello"); in TEST_F()
1504 EXPECT_EQ(5, env_->GetStringLength(s)); in TEST_F()
1505 EXPECT_EQ(5, env_->GetStringUTFLength(s)); in TEST_F()
1508 s = env_->NewStringUTF("\xed\xa0\x81\xed\xb0\x80"); in TEST_F()
1510 EXPECT_EQ(2, env_->GetStringLength(s)); in TEST_F()
1513 EXPECT_EQ(4, env_->GetStringUTFLength(s)); in TEST_F()
1514 const char* chars = env_->GetStringUTFChars(s, nullptr); in TEST_F()
1516 env_->ReleaseStringUTFChars(s, chars); in TEST_F()
1519 const jchar* jchars = env_->GetStringChars(s, nullptr); in TEST_F()
1522 env_->ReleaseStringChars(s, jchars); in TEST_F()
1525 s = env_->NewStringUTF("\xed\xa0\x81\xed\xb0\x80 \xf0\x9f\x8f\xa0"); in TEST_F()
1530 EXPECT_EQ(5, env_->GetStringLength(s)); in TEST_F()
1531 jchars = env_->GetStringChars(s, nullptr); in TEST_F()
1538 env_->ReleaseStringChars(s, jchars); in TEST_F()
1540 EXPECT_EQ(9, env_->GetStringUTFLength(s)); in TEST_F()
1541 chars = env_->GetStringUTFChars(s, nullptr); in TEST_F()
1543 env_->ReleaseStringUTFChars(s, chars); in TEST_F()
1547 s = env_->NewStringUTF("\x24 \xc2\xa2 \xe2\x82\xac \xf0\x9f\x8f\xa0"); in TEST_F()
1549 EXPECT_EQ(8, env_->GetStringLength(s)); in TEST_F()
1550 EXPECT_EQ(13, env_->GetStringUTFLength(s)); in TEST_F()
1556 s = env_->NewString(chars, 0); in TEST_F()
1558 EXPECT_EQ(0, env_->GetStringLength(s)); in TEST_F()
1559 EXPECT_EQ(0, env_->GetStringUTFLength(s)); in TEST_F()
1560 s = env_->NewString(chars, 2); in TEST_F()
1562 EXPECT_EQ(2, env_->GetStringLength(s)); in TEST_F()
1563 EXPECT_EQ(2, env_->GetStringUTFLength(s)); in TEST_F()
1569 jstring s = env_->NewString(nullptr, 0); in TEST_F()
1571 EXPECT_EQ(0, env_->GetStringLength(s)); in TEST_F()
1576 env_->NewString(nullptr, 1); in TEST_F()
1583 env_->NewString(nullptr, -1); in TEST_F()
1585 env_->NewString(nullptr, std::numeric_limits<jint>::min()); in TEST_F()
1588 env_->NewString(nullptr, -1); in TEST_F()
1590 env_->NewString(nullptr, std::numeric_limits<jint>::min()); in TEST_F()
1600 jstring s = env_->NewStringUTF("hello"); in TEST_F()
1603 env_->GetStringRegion(s, -1, 0, nullptr); in TEST_F()
1605 env_->GetStringRegion(s, 0, -1, nullptr); in TEST_F()
1607 env_->GetStringRegion(s, 0, 10, nullptr); in TEST_F()
1609 env_->GetStringRegion(s, 10, 1, nullptr); in TEST_F()
1612 env_->GetStringRegion(s, 0x7fffffff, 0x7fffffff, nullptr); in TEST_F()
1616 env_->GetStringRegion(s, 1, 2, &chars[1]); in TEST_F()
1623 env_->GetStringRegion(s, 2, 0, nullptr); in TEST_F()
1625 env_->GetStringRegion(s, 123, 0, nullptr); in TEST_F()
1628 env_->GetStringUTFRegion(s, -1, 0, nullptr); in TEST_F()
1630 env_->GetStringUTFRegion(s, 0, -1, nullptr); in TEST_F()
1632 env_->GetStringUTFRegion(s, 0, 10, nullptr); in TEST_F()
1634 env_->GetStringUTFRegion(s, 10, 1, nullptr); in TEST_F()
1637 env_->GetStringUTFRegion(s, 0x7fffffff, 0x7fffffff, nullptr); in TEST_F()
1641 env_->GetStringUTFRegion(s, 1, 2, &bytes[1]); in TEST_F()
1648 env_->GetStringUTFRegion(s, 2, 0, nullptr); in TEST_F()
1650 env_->GetStringUTFRegion(s, 123, 0, nullptr); in TEST_F()
1659 EXPECT_EQ(env_->GetStringUTFChars(nullptr, nullptr), nullptr); in TEST_F()
1664 EXPECT_EQ(env_->GetStringUTFChars(nullptr, nullptr), nullptr); in TEST_F()
1669 jstring s = env_->NewStringUTF("hello"); in TEST_F()
1672 const char* utf = env_->GetStringUTFChars(s, nullptr); in TEST_F()
1674 env_->ReleaseStringUTFChars(s, utf); in TEST_F()
1677 utf = env_->GetStringUTFChars(s, &is_copy); in TEST_F()
1680 env_->ReleaseStringUTFChars(s, utf); in TEST_F()
1684 jstring s = env_->NewStringUTF("hello"); in TEST_F()
1685 ScopedObjectAccess soa(env_); in TEST_F()
1690 const jchar* chars = env_->GetStringChars(s, nullptr); in TEST_F()
1696 env_->ReleaseStringChars(s, chars); in TEST_F()
1699 chars = env_->GetStringChars(s, &is_copy); in TEST_F()
1710 env_->ReleaseStringChars(s, chars); in TEST_F()
1714 jstring s = env_->NewStringUTF("hello"); in TEST_F()
1718 const jchar* chars = env_->GetStringCritical(s, nullptr); in TEST_F()
1724 env_->ReleaseStringCritical(s, chars); in TEST_F()
1727 chars = env_->GetStringCritical(s, &is_copy); in TEST_F()
1739 env_->ReleaseStringCritical(s, chars); in TEST_F()
1744 jstring s_16 = env_->NewStringUTF("\xed\xa0\x81\xed\xb0\x80"); in TEST_F()
1745 chars = env_->GetStringCritical(s_16, &is_copy_16); in TEST_F()
1746 EXPECT_EQ(2, env_->GetStringLength(s_16)); in TEST_F()
1747 EXPECT_EQ(4, env_->GetStringUTFLength(s_16)); in TEST_F()
1748 env_->ReleaseStringCritical(s_16, chars); in TEST_F()
1753 jclass java_lang_Class = env_->FindClass("java/lang/Class"); in TEST_F()
1756 jobjectArray array = env_->NewObjectArray(1, java_lang_Class, nullptr); in TEST_F()
1758 EXPECT_EQ(env_->GetObjectArrayElement(array, 0), nullptr); in TEST_F()
1759 env_->SetObjectArrayElement(array, 0, java_lang_Class); in TEST_F()
1760 EXPECT_TRUE(env_->IsSameObject(env_->GetObjectArrayElement(array, 0), java_lang_Class)); in TEST_F()
1763 env_->SetObjectArrayElement(array, -1, java_lang_Class); in TEST_F()
1767 env_->SetObjectArrayElement(array, 1, java_lang_Class); in TEST_F()
1771 env_->SetObjectArrayElement(array, 0, env_->NewStringUTF("not a jclass!")); in TEST_F()
1777 EXPECT_EQ(nullptr, env_->GetObjectArrayElement(nullptr, 0)); in TEST_F()
1779 env_->SetObjectArrayElement(nullptr, 0, nullptr); in TEST_F()
1782 EXPECT_EQ(nullptr, env_->GetObjectArrayElement(nullptr, 0)); in TEST_F()
1784 env_->SetObjectArrayElement(nullptr, 0, nullptr); in TEST_F()
1791 jfieldID fid = env_->GetStaticFieldID(c, field_name, sig); \
1793 env_->SetStatic ## type ## Field(c, fid, value1); \
1794 expect_eq(value1, env_->GetStatic ## type ## Field(c, fid)); \
1795 env_->SetStatic ## type ## Field(c, fid, value2); \
1796 expect_eq(value2, env_->GetStatic ## type ## Field(c, fid)); \
1801 env_->GetStatic ## type ## Field(nullptr, fid); \
1802 env_->SetStatic ## type ## Field(nullptr, fid, value1); \
1805 env_->GetStatic ## type ## Field(c, nullptr); \
1807 env_->SetStatic ## type ## Field(c, nullptr, value1); \
1811 env_->GetStatic ## type ## Field(nullptr, fid); \
1813 env_->SetStatic ## type ## Field(nullptr, fid, value1); \
1815 env_->GetStatic ## type ## Field(c, nullptr); \
1817 env_->SetStatic ## type ## Field(c, nullptr, value1); \
1824 jfieldID fid = env_->GetFieldID(c, field_name, sig); \
1826 env_->Set ## type ## Field(instance, fid, value1); \
1827 expect_eq(value1, env_->Get ## type ## Field(instance, fid)); \
1828 env_->Set ## type ## Field(instance, fid, value2); \
1829 expect_eq(value2, env_->Get ## type ## Field(instance, fid)); \
1833 env_->Get ## type ## Field(nullptr, fid); \
1835 env_->Set ## type ## Field(nullptr, fid, value1); \
1837 env_->Get ## type ## Field(instance, nullptr); \
1839 env_->Set ## type ## Field(instance, nullptr, value1); \
1842 env_->Get ## type ## Field(nullptr, fid); \
1844 env_->Set ## type ## Field(nullptr, fid, value1); \
1846 env_->Get ## type ## Field(instance, nullptr); \
1848 env_->Set ## type ## Field(instance, nullptr, value1); \
1859 jclass c = env_->FindClass(cname); \
1861 jobject o = env_->AllocObject(c); \
1893 jfieldID fid = env_->GetStaticFieldID(c, field_name, sig); \
1896 env_->Get ## type ## Field(uc, fid); \
1898 env_->Set ## type ## Field(uc, fid, value1); \
1907 jclass c = env_->FindClass("AllFields"); in TEST_F()
1909 jclass uc = env_->FindClass("AllFieldsUnrelated"); in TEST_F()
1930 jclass c = env_->FindClass(cname); \
1932 jobject o = env_->AllocObject(c); \
1935 jstring s1 = env_->NewStringUTF("hello"); \
1937 jstring s2 = env_->NewStringUTF("world"); \
1940 jfieldID s_fid = env_->GetStaticFieldID(c, "sObject", "Ljava/lang/Object;"); \
1942 jfieldID i_fid = env_->GetFieldID(c, "iObject", "Ljava/lang/Object;"); \
1945 env_->SetStaticObjectField(c, s_fid, s1); \
1946 ASSERT_TRUE(env_->IsSameObject(s1, env_->GetStaticObjectField(c, s_fid))); \
1947 env_->SetStaticObjectField(c, s_fid, s2); \
1948 ASSERT_TRUE(env_->IsSameObject(s2, env_->GetStaticObjectField(c, s_fid))); \
1950 env_->SetObjectField(o, i_fid, s1); \
1951 ASSERT_TRUE(env_->IsSameObject(s1, env_->GetObjectField(o, i_fid))); \
1952 env_->SetObjectField(o, i_fid, s2); \
1953 ASSERT_TRUE(env_->IsSameObject(s2, env_->GetObjectField(o, i_fid))); \
1965 EXPECT_EQ(env_->NewLocalRef(nullptr), nullptr); in TEST_F()
1969 jstring s = env_->NewStringUTF(""); in TEST_F()
1971 jobject o = env_->NewLocalRef(s); in TEST_F()
1975 EXPECT_EQ(JNILocalRefType, env_->GetObjectRefType(o)); in TEST_F()
1979 env_->DeleteLocalRef(nullptr); in TEST_F()
1986 jstring s = env_->NewStringUTF(""); in TEST_F()
1988 env_->DeleteLocalRef(s); in TEST_F()
1995 env_->DeleteLocalRef(s); in TEST_F()
1999 env_->DeleteLocalRef(s); in TEST_F()
2005 s = env_->NewStringUTF(""); in TEST_F()
2007 jobject o = env_->NewLocalRef(s); in TEST_F()
2010 env_->DeleteLocalRef(s); in TEST_F()
2011 env_->DeleteLocalRef(o); in TEST_F()
2019 ASSERT_EQ(JNI_OK, env_->PushLocalFrame(0)); in TEST_F()
2020 env_->PopLocalFrame(nullptr); in TEST_F()
2026 ASSERT_EQ(JNI_ERR, env_->PushLocalFrame(-1)); in TEST_F()
2033 jobject original = env_->NewStringUTF(""); in TEST_F()
2038 ScopedObjectAccess soa(env_); in TEST_F()
2040 ASSERT_EQ(JNI_OK, env_->PushLocalFrame(4)); in TEST_F()
2041 outer = env_->NewLocalRef(original); in TEST_F()
2044 ASSERT_EQ(JNI_OK, env_->PushLocalFrame(4)); in TEST_F()
2045 inner1 = env_->NewLocalRef(outer); in TEST_F()
2046 inner2 = env_->NewStringUTF("survivor"); in TEST_F()
2047 EXPECT_NE(env_->PopLocalFrame(inner2), nullptr); in TEST_F()
2050 EXPECT_EQ(JNILocalRefType, env_->GetObjectRefType(original)); in TEST_F()
2051 EXPECT_EQ(JNILocalRefType, env_->GetObjectRefType(outer)); in TEST_F()
2054 EXPECT_EQ(JNIInvalidRefType, env_->GetObjectRefType(inner1)); in TEST_F()
2062 EXPECT_EQ(JNIInvalidRefType, env_->GetObjectRefType(inner2)); in TEST_F()
2066 EXPECT_EQ(env_->PopLocalFrame(nullptr), nullptr); in TEST_F()
2068 EXPECT_EQ(JNILocalRefType, env_->GetObjectRefType(original)); in TEST_F()
2070 EXPECT_EQ(JNIInvalidRefType, env_->GetObjectRefType(outer)); in TEST_F()
2072 EXPECT_EQ(JNIInvalidRefType, env_->GetObjectRefType(inner1)); in TEST_F()
2074 EXPECT_EQ(JNIInvalidRefType, env_->GetObjectRefType(inner2)); in TEST_F()
2080 ASSERT_NE(JNI_OK, env_->PushLocalFrame(std::numeric_limits<jint>::max())); in TEST_F()
2081 ASSERT_TRUE(env_->ExceptionCheck()); in TEST_F()
2082 env_->ExceptionClear(); in TEST_F()
2086 ASSERT_EQ(JNI_OK, env_->PushLocalFrame(10)); in TEST_F()
2087 ASSERT_NE(JNI_OK, env_->PushLocalFrame(std::numeric_limits<jint>::max() - 10)); in TEST_F()
2088 ASSERT_TRUE(env_->ExceptionCheck()); in TEST_F()
2089 env_->ExceptionClear(); in TEST_F()
2090 EXPECT_EQ(env_->PopLocalFrame(nullptr), nullptr); in TEST_F()
2096 ASSERT_EQ(JNI_OK, env_->PushLocalFrame(1024)); in TEST_F()
2097 EXPECT_EQ(env_->PopLocalFrame(nullptr), nullptr); in TEST_F()
2101 EXPECT_EQ(env_->NewGlobalRef(nullptr), nullptr); in TEST_F()
2105 jstring s = env_->NewStringUTF(""); in TEST_F()
2107 jobject o = env_->NewGlobalRef(s); in TEST_F()
2111 EXPECT_EQ(env_->GetObjectRefType(o), JNIGlobalRefType); in TEST_F()
2115 env_->DeleteGlobalRef(nullptr); in TEST_F()
2122 jstring s = env_->NewStringUTF(""); in TEST_F()
2125 jobject o = env_->NewGlobalRef(s); in TEST_F()
2127 env_->DeleteGlobalRef(o); in TEST_F()
2134 env_->DeleteGlobalRef(o); in TEST_F()
2138 env_->DeleteGlobalRef(o); in TEST_F()
2144 jobject o1 = env_->NewGlobalRef(s); in TEST_F()
2146 jobject o2 = env_->NewGlobalRef(s); in TEST_F()
2149 env_->DeleteGlobalRef(o1); in TEST_F()
2150 env_->DeleteGlobalRef(o2); in TEST_F()
2154 EXPECT_EQ(env_->NewWeakGlobalRef(nullptr), nullptr); in TEST_F()
2158 jstring s = env_->NewStringUTF(""); in TEST_F()
2160 jobject o = env_->NewWeakGlobalRef(s); in TEST_F()
2164 EXPECT_EQ(env_->GetObjectRefType(o), JNIWeakGlobalRefType); in TEST_F()
2168 env_->DeleteWeakGlobalRef(nullptr); in TEST_F()
2175 jstring s = env_->NewStringUTF(""); in TEST_F()
2178 jobject o = env_->NewWeakGlobalRef(s); in TEST_F()
2180 env_->DeleteWeakGlobalRef(o); in TEST_F()
2187 env_->DeleteWeakGlobalRef(o); in TEST_F()
2191 env_->DeleteWeakGlobalRef(o); in TEST_F()
2197 jobject o1 = env_->NewWeakGlobalRef(s); in TEST_F()
2199 jobject o2 = env_->NewWeakGlobalRef(s); in TEST_F()
2202 env_->DeleteWeakGlobalRef(o1); in TEST_F()
2203 env_->DeleteWeakGlobalRef(o2); in TEST_F()
2208 env_->ExceptionClear(); in TEST_F()
2209 env_->ExceptionDescribe(); in TEST_F()
2213 jclass exception_class = env_->FindClass("java/lang/RuntimeException"); in TEST_F()
2215 jthrowable exception = reinterpret_cast<jthrowable>(env_->AllocObject(exception_class)); in TEST_F()
2218 EXPECT_EQ(JNI_OK, env_->Throw(exception)); in TEST_F()
2219 EXPECT_TRUE(env_->ExceptionCheck()); in TEST_F()
2220 jthrowable thrown_exception = env_->ExceptionOccurred(); in TEST_F()
2221 env_->ExceptionClear(); in TEST_F()
2222 EXPECT_TRUE(env_->IsSameObject(exception, thrown_exception)); in TEST_F()
2226 EXPECT_EQ(JNI_ERR, env_->Throw(nullptr)); in TEST_F()
2229 EXPECT_EQ(JNI_ERR, env_->Throw(nullptr)); in TEST_F()
2235 jclass exception_class = env_->FindClass("java/lang/RuntimeException"); in TEST_F()
2240 EXPECT_EQ(JNI_OK, env_->ThrowNew(exception_class, "hello world")); in TEST_F()
2241 EXPECT_TRUE(env_->ExceptionCheck()); in TEST_F()
2242 thrown_exception = env_->ExceptionOccurred(); in TEST_F()
2243 env_->ExceptionClear(); in TEST_F()
2244 EXPECT_TRUE(env_->IsInstanceOf(thrown_exception, exception_class)); in TEST_F()
2246 EXPECT_EQ(JNI_OK, env_->ThrowNew(exception_class, nullptr)); in TEST_F()
2247 EXPECT_TRUE(env_->ExceptionCheck()); in TEST_F()
2248 thrown_exception = env_->ExceptionOccurred(); in TEST_F()
2249 env_->ExceptionClear(); in TEST_F()
2250 EXPECT_TRUE(env_->IsInstanceOf(thrown_exception, exception_class)); in TEST_F()
2255 EXPECT_EQ(JNI_ERR, env_->ThrowNew(nullptr, nullptr)); in TEST_F()
2258 EXPECT_EQ(JNI_ERR, env_->ThrowNew(nullptr, nullptr)); in TEST_F()
2280 jclass buffer_class = env_->FindClass("java/nio/Buffer"); in TEST_F()
2284 jobject buffer = env_->NewDirectByteBuffer(bytes, sizeof(bytes)); in TEST_F()
2286 ASSERT_TRUE(env_->IsInstanceOf(buffer, buffer_class)); in TEST_F()
2287 ASSERT_EQ(env_->GetDirectBufferAddress(buffer), bytes); in TEST_F()
2288 ASSERT_EQ(env_->GetDirectBufferCapacity(buffer), static_cast<jlong>(sizeof(bytes))); in TEST_F()
2292 env_->NewDirectByteBuffer(bytes, static_cast<jlong>(INT_MAX) + 1); in TEST_F()
2302 jclass object_class = env_->FindClass("java/lang/Object"); in TEST_F()
2304 jobject object = env_->AllocObject(object_class); in TEST_F()
2308 jclass imse_class = env_->FindClass("java/lang/IllegalMonitorStateException"); in TEST_F()
2314 env_->MonitorExit(object); in TEST_F()
2315 EXPECT_TRUE(env_->ExceptionCheck()); in TEST_F()
2316 thrown_exception = env_->ExceptionOccurred(); in TEST_F()
2317 env_->ExceptionClear(); in TEST_F()
2318 EXPECT_TRUE(env_->IsInstanceOf(thrown_exception, imse_class)); in TEST_F()
2321 env_->MonitorEnter(object); in TEST_F()
2322 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
2324 env_->MonitorExit(object); in TEST_F()
2325 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
2330 env_->MonitorEnter(object); in TEST_F()
2331 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
2335 env_->MonitorExit(object); in TEST_F()
2336 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
2340 env_->MonitorExit(object); in TEST_F()
2341 EXPECT_TRUE(env_->ExceptionCheck()); in TEST_F()
2342 thrown_exception = env_->ExceptionOccurred(); in TEST_F()
2343 env_->ExceptionClear(); in TEST_F()
2344 EXPECT_TRUE(env_->IsInstanceOf(thrown_exception, imse_class)); in TEST_F()
2349 env_->MonitorEnter(nullptr); in TEST_F()
2351 env_->MonitorExit(nullptr); in TEST_F()
2365 env_->MonitorEnter(jobj_); in TEST_F()
2366 EXPECT_FALSE(env_->ExceptionCheck()); in TEST_F()
2369 env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_); in TEST_F()
2386 env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_); in TEST_F()
2417 jclass object_class = env_->FindClass("java/lang/Object"); in TEST_F()
2419 jobject object = env_->AllocObject(object_class); in TEST_F()
2421 global_ref = env_->NewGlobalRef(object); in TEST_F()
2425 env_->MonitorEnter(global_ref); in TEST_F()
2426 ASSERT_TRUE(IsLocked(env_, global_ref)); in TEST_F()
2431 jint attach_result = vm_->AttachCurrentThread(&env_, nullptr); in TEST_F()
2435 ASSERT_FALSE(IsLocked(env_, global_ref)); in TEST_F()
2438 env_->DeleteGlobalRef(global_ref); in TEST_F()
2495 memcpy(&env_override, env_->functions, sizeof(JNINativeInterface)); in TEST_F()
2497 gOriginalEnv = env_->functions; in TEST_F()
2501 jclass local = env_->FindClass("java/lang/Object"); in TEST_F()
2507 jobject global = env_->NewGlobalRef(local); in TEST_F()
2509 env_->DeleteGlobalRef(global); in TEST_F()
2514 jobject global2 = env_->NewGlobalRef(local); in TEST_F()
2516 env_->DeleteGlobalRef(global2); in TEST_F()
2537 reinterpret_cast<void*>(env_)); in TEST_F()