< prev index next >

test/hotspot/jtreg/runtime/clinit/libClassInitBarrier.cpp

Print this page

 37 static jfieldID test_A_f_id;
 38 
 39 extern "C" {
 40     JNIEXPORT jboolean JNICALL Java_ClassInitBarrier_init(JNIEnv* env, jclass cls) {
 41         jclass runnable = env->FindClass("java/lang/Runnable");
 42         if (runnable == nullptr)  return JNI_FALSE;
 43 
 44         methodId = env->GetMethodID(runnable, "run", "()V");
 45         if (methodId == nullptr)  return JNI_FALSE;
 46 
 47         return JNI_TRUE;
 48     }
 49 
 50     JNIEXPORT jboolean JNICALL Java_ClassInitBarrier_00024Test_00024A_init(JNIEnv* env, jclass cls, jclass arg1) {
 51         test_class_A = (jclass)env->NewGlobalRef(cls);
 52         if (test_class_A == nullptr)  return JNI_FALSE;
 53 
 54         test_class_B = (jclass)env->NewGlobalRef(arg1);
 55         if (test_class_B == nullptr)  return JNI_FALSE;
 56 
 57         test_staticM_id = env->GetStaticMethodID(test_class_A, "staticM", "(Ljava/lang/Runnable;)V");
 58         if (test_staticM_id == nullptr)  return JNI_FALSE;
 59 
 60         test_staticS_id = env->GetStaticMethodID(test_class_A, "staticS", "(Ljava/lang/Runnable;)V");
 61         if (test_staticS_id == nullptr)  return JNI_FALSE;
 62 
 63         test_staticN_id = env->GetStaticMethodID(test_class_A, "staticN", "(Ljava/lang/Runnable;)V");
 64         if (test_staticN_id == nullptr)  return JNI_FALSE;
 65 
 66         test_A_m_id = env->GetMethodID(test_class_A, "m", "()V");
 67         if (test_A_m_id == nullptr)  return JNI_FALSE;
 68 
 69         test_staticF_id = env->GetStaticFieldID(test_class_A, "staticF", "I");
 70         if (test_staticF_id == nullptr)  return JNI_FALSE;
 71 
 72         test_A_f_id = env->GetFieldID(test_class_A, "f", "I");
 73         if (test_A_f_id == nullptr)  return JNI_FALSE;
 74 
 75         return JNI_TRUE;
 76     }
 77 
 78     JNIEXPORT void JNICALL Java_ClassInitBarrier_00024Test_00024A_staticN(JNIEnv* env, jclass cls, jobject action) {
 79         env->CallVoidMethod(action, methodId);
 80     }
 81 
 82     JNIEXPORT void JNICALL Java_ClassInitBarrier_00024Test_testInvokeStaticJNI(JNIEnv* env, jclass cls, jobject action) {
 83         env->CallStaticVoidMethod(test_class_A, test_staticM_id, action);
 84     }
 85 
 86     JNIEXPORT void JNICALL Java_ClassInitBarrier_00024Test_testInvokeStaticSyncJNI(JNIEnv* env, jclass cls, jobject action) {
 87         env->CallStaticVoidMethod(test_class_A, test_staticS_id, action);
 88     }
 89 
 90     JNIEXPORT void JNICALL Java_ClassInitBarrier_00024Test_testInvokeStaticNativeJNI(JNIEnv* env, jclass cls, jobject action) {
 91         env->CallStaticVoidMethod(test_class_A, test_staticN_id, action);
 92     }
 93 
 94     JNIEXPORT jint JNICALL Java_ClassInitBarrier_00024Test_testGetStaticJNI(JNIEnv* env, jclass cls, jobject action) {
 95         jint v = env->GetStaticIntField(test_class_A, test_staticF_id); // int v = A.staticF;
 96         env->CallVoidMethod(action, methodId);                          // action.run();
 97         return v;
 98     }
 99 
100     JNIEXPORT void JNICALL Java_ClassInitBarrier_00024Test_testPutStaticJNI(JNIEnv* env, jclass cls, jobject action) {
101         env->SetStaticIntField(test_class_A, test_staticF_id, 1); // A.staticF = 1;
102         env->CallVoidMethod(action, methodId);                    // action.run();
103     }
104 
105     JNIEXPORT jobject JNICALL Java_ClassInitBarrier_00024Test_testNewInstanceAJNI(JNIEnv* env, jclass cls, jobject action) {
106         jobject obj = env->AllocObject(test_class_A); // A obj = new A();
107         if (env->ExceptionOccurred()) {
108           return nullptr;
109         } else if (obj == nullptr) {
110           jclass errorClass = env->FindClass("java/lang/AssertionError");
111           int ret = env->ThrowNew(errorClass, "JNI: AllocObject: allocation failed, but no exception thrown");

 37 static jfieldID test_A_f_id;
 38 
 39 extern "C" {
 40     JNIEXPORT jboolean JNICALL Java_ClassInitBarrier_init(JNIEnv* env, jclass cls) {
 41         jclass runnable = env->FindClass("java/lang/Runnable");
 42         if (runnable == nullptr)  return JNI_FALSE;
 43 
 44         methodId = env->GetMethodID(runnable, "run", "()V");
 45         if (methodId == nullptr)  return JNI_FALSE;
 46 
 47         return JNI_TRUE;
 48     }
 49 
 50     JNIEXPORT jboolean JNICALL Java_ClassInitBarrier_00024Test_00024A_init(JNIEnv* env, jclass cls, jclass arg1) {
 51         test_class_A = (jclass)env->NewGlobalRef(cls);
 52         if (test_class_A == nullptr)  return JNI_FALSE;
 53 
 54         test_class_B = (jclass)env->NewGlobalRef(arg1);
 55         if (test_class_B == nullptr)  return JNI_FALSE;
 56 
 57         test_staticM_id = env->GetStaticMethodID(test_class_A, "staticM", "(Ljava/lang/Runnable;LClassInitBarrier$MyValue;)V");
 58         if (test_staticM_id == nullptr)  return JNI_FALSE;
 59 
 60         test_staticS_id = env->GetStaticMethodID(test_class_A, "staticS", "(Ljava/lang/Runnable;LClassInitBarrier$MyValue;)V");
 61         if (test_staticS_id == nullptr)  return JNI_FALSE;
 62 
 63         test_staticN_id = env->GetStaticMethodID(test_class_A, "staticN", "(Ljava/lang/Runnable;LClassInitBarrier$MyValue;)V");
 64         if (test_staticN_id == nullptr)  return JNI_FALSE;
 65 
 66         test_A_m_id = env->GetMethodID(test_class_A, "m", "()V");
 67         if (test_A_m_id == nullptr)  return JNI_FALSE;
 68 
 69         test_staticF_id = env->GetStaticFieldID(test_class_A, "staticF", "I");
 70         if (test_staticF_id == nullptr)  return JNI_FALSE;
 71 
 72         test_A_f_id = env->GetFieldID(test_class_A, "f", "I");
 73         if (test_A_f_id == nullptr)  return JNI_FALSE;
 74 
 75         return JNI_TRUE;
 76     }
 77 
 78     JNIEXPORT void JNICALL Java_ClassInitBarrier_00024Test_00024A_staticN(JNIEnv* env, jclass cls, jobject action) {
 79         env->CallVoidMethod(action, methodId);
 80     }
 81 
 82     JNIEXPORT void JNICALL Java_ClassInitBarrier_00024Test_testInvokeStaticJNI(JNIEnv* env, jclass cls, jobject action, jobject val) {
 83         env->CallStaticVoidMethod(test_class_A, test_staticM_id, action, val);
 84     }
 85 
 86     JNIEXPORT void JNICALL Java_ClassInitBarrier_00024Test_testInvokeStaticSyncJNI(JNIEnv* env, jclass cls, jobject action, jobject val) {
 87         env->CallStaticVoidMethod(test_class_A, test_staticS_id, action, val);
 88     }
 89 
 90     JNIEXPORT void JNICALL Java_ClassInitBarrier_00024Test_testInvokeStaticNativeJNI(JNIEnv* env, jclass cls, jobject action, jobject val) {
 91         env->CallStaticVoidMethod(test_class_A, test_staticN_id, action, val);
 92     }
 93 
 94     JNIEXPORT jint JNICALL Java_ClassInitBarrier_00024Test_testGetStaticJNI(JNIEnv* env, jclass cls, jobject action) {
 95         jint v = env->GetStaticIntField(test_class_A, test_staticF_id); // int v = A.staticF;
 96         env->CallVoidMethod(action, methodId);                          // action.run();
 97         return v;
 98     }
 99 
100     JNIEXPORT void JNICALL Java_ClassInitBarrier_00024Test_testPutStaticJNI(JNIEnv* env, jclass cls, jobject action) {
101         env->SetStaticIntField(test_class_A, test_staticF_id, 1); // A.staticF = 1;
102         env->CallVoidMethod(action, methodId);                    // action.run();
103     }
104 
105     JNIEXPORT jobject JNICALL Java_ClassInitBarrier_00024Test_testNewInstanceAJNI(JNIEnv* env, jclass cls, jobject action) {
106         jobject obj = env->AllocObject(test_class_A); // A obj = new A();
107         if (env->ExceptionOccurred()) {
108           return nullptr;
109         } else if (obj == nullptr) {
110           jclass errorClass = env->FindClass("java/lang/AssertionError");
111           int ret = env->ThrowNew(errorClass, "JNI: AllocObject: allocation failed, but no exception thrown");
< prev index next >