< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.cpp

Print this page
rev 52828 : 8213501: Deploy ExceptionJniWrapper for a few tests
Summary:
Reviewed-by:

*** 36,66 **** * Method: criticalNative * Signature: (JJ)V */ JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIGlobalRefLocker_criticalNative (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) { ! ExceptionCheckingJniEnvPtr env(jni_env); jobject obj; jobject gref; time_t start_time, current_time; if (objFieldId == NULL) { ! jclass klass = env->GetObjectClass(o); ! objFieldId = env->GetFieldID(klass, "obj", "Ljava/lang/Object;"); } ! obj = env->GetObjectField(o, objFieldId); ! env->SetObjectField(o, objFieldId, NULL); start_time = time(NULL); enterTime /= 1000; current_time = 0; while (current_time - start_time < enterTime) { ! gref = env->NewGlobalRef(obj); mssleep((long) sleepTime); ! env->DeleteGlobalRef(gref); mssleep((long) sleepTime); current_time = time(NULL); } ! env->SetObjectField(o, objFieldId, obj); } } --- 36,66 ---- * Method: criticalNative * Signature: (JJ)V */ JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIGlobalRefLocker_criticalNative (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) { ! ExceptionCheckingJniEnvPtr jni(jni_env); jobject obj; jobject gref; time_t start_time, current_time; if (objFieldId == NULL) { ! jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL); ! objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } ! obj = jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); ! jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); start_time = time(NULL); enterTime /= 1000; current_time = 0; while (current_time - start_time < enterTime) { ! gref = jni->NewGlobalRef(obj, TRACE_JNI_CALL); mssleep((long) sleepTime); ! jni->DeleteGlobalRef(gref, TRACE_JNI_CALL); mssleep((long) sleepTime); current_time = time(NULL); } ! jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL); } }
< prev index next >