8214149: Move out assignments when not using NSK*VERIFY macros

Move out the assignments from ifs

Reviewed-by: sspitsyn, cjplummer
This commit is contained in:
Jean Christophe Beyler 2018-11-21 10:46:45 -08:00
parent 10cd386ac3
commit 937fe3be82
53 changed files with 331 additions and 216 deletions

View File

@ -36,7 +36,8 @@ JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *res
// can't use NSK_DISPLAY since needed for nsk_ functions initialization isn't done here
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
jni = (JNIEnv*) nsk_aod_createJNIEnv(vm);
if (jni == NULL)
return JNI_ERR;
printf("%s: initialization was done\n", AGENT_NAME);

View File

@ -39,7 +39,8 @@ JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *res
// can't use NSK_DISPLAY since needed for nsk_ functions initialization isn't done here
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
jni = (JNIEnv*) nsk_aod_createJNIEnv(vm);
if (jni == NULL)
return JNI_ERR;
printf("%s: initialization was done\n", AGENT_NAME);

View File

@ -41,7 +41,8 @@ JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *res
// can't use NSK_DISPLAY since needed for nsk_ functions initialization isn't done here
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
jni = (JNIEnv*) nsk_aod_createJNIEnv(vm);
if (jni == NULL)
return JNI_ERR;
printf("%s: initialization was done\n", AGENT_NAME);

View File

@ -38,7 +38,8 @@ extern "C" {
JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) {
JNIEnv* jni;
if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
jni = (JNIEnv*) nsk_aod_createJNIEnv(vm);
if (jni == NULL)
return JNI_ERR;
// can't use NSK_DISPLAY since needed for nsk_ functions initialization isn't done here

View File

@ -120,18 +120,22 @@ ClassLoad(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) {
NSK_COMPLAIN0("TEST FAILURE: unable to obtain a class signature\n");
}
if ((i = findSig(sig, 1)) != -1) {
i = findSig(sig, 1);
if (i != -1) {
clsEvents[i]++;
NSK_DISPLAY1("CHECK PASSED: ClassLoad event received for the class \"%s\" as expected\n",
sig);
}
else if ((i = findSig(sig, 0)) != -1) {
else {
i = findSig(sig, 0);
if (i != -1) {
result = STATUS_FAILED;
primClsEvents[i]++;
NSK_COMPLAIN1(
"TEST FAILED: JVMTI_EVENT_CLASS_LOAD event received for\n"
"\t a primitive class/array of primitive types with the signature \"%s\"\n",
sig);
}
}
unlock(jvmti_env, env);

View File

@ -271,7 +271,8 @@ Java_nsk_jvmti_ClassPrepare_classprep001_getReady(JNIEnv *env, jclass cls) {
return;
}
if ((err = (jvmti->GetCurrentThread(&prep_thread))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCurrentThread(&prep_thread);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to get current thread: %s (%d)\n", TranslateError(err), err);
result = STATUS_FAILED;
return;
@ -298,7 +299,8 @@ Java_nsk_jvmti_ClassPrepare_classprep001_check(JNIEnv *env, jclass cls) {
return STATUS_FAILED;
}
if ((err = (jvmti->GetCurrentThread(&prep_thread))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCurrentThread(&prep_thread);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to get current thread: %s (%d)\n", TranslateError(err), err);
return STATUS_FAILED;
}

View File

@ -270,7 +270,8 @@ Java_nsk_jvmti_Exception_exception001_check(JNIEnv *env, jclass cls) {
return STATUS_FAILED;
}
if ((err = (jvmti->GetCurrentThread(&thread))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCurrentThread(&thread);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to get current thread: %s (%d)\n", TranslateError(err), err);
result = STATUS_FAILED;
return STATUS_FAILED;

View File

@ -80,7 +80,8 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_ERR;
}
if ((err = (jvmti->GetCapabilities(&caps))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCapabilities(&caps);
if (err != JVMTI_ERROR_NONE) {
printf("(GetCapabilities) unexpected error: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;

View File

@ -63,7 +63,8 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_ERR;
}
if ((err = (jvmti->GetCapabilities(&caps))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCapabilities(&caps);
if (err != JVMTI_ERROR_NONE) {
printf("(GetCapabilities) unexpected error: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;

View File

@ -438,13 +438,15 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_ERR;
}
if ((err = (jvmti->GetCapabilities(&caps))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCapabilities(&caps);
if (err != JVMTI_ERROR_NONE) {
printf("(GetCapabilities) unexpected error: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;
}
if ((err = (jvmti->GetCapabilities(&caps))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCapabilities(&caps);
if (err != JVMTI_ERROR_NONE) {
printf("(GetCapabilities) unexpected error: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;

View File

@ -58,7 +58,8 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_ERR;
}
if ((err = (jvmti->GetCapabilities(&caps))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCapabilities(&caps);
if (err != JVMTI_ERROR_NONE) {
printf("(GetCapabilities) unexpected error: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;

View File

@ -58,7 +58,8 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_ERR;
}
if ((err = (jvmti->GetCapabilities(&caps))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCapabilities(&caps);
if (err != JVMTI_ERROR_NONE) {
printf("(GetCapabilities) unexpected error: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;

View File

@ -63,7 +63,8 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_ERR;
}
if ((err = (jvmti->GetCapabilities(&caps))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCapabilities(&caps);
if (err != JVMTI_ERROR_NONE) {
printf("(GetCapabilities) unexpected error: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;

View File

@ -70,15 +70,15 @@ static void doRedirect(JNIEnv *env) {
if (verbose)
printf("\ndoRedirect: obtaining the JNI function table ...\n");
if ((err = jvmti->GetJNIFunctionTable(&orig_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
env->FatalError("failed to get original JNI function table");
}
if ((err = jvmti->GetJNIFunctionTable(&redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get redirected JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -91,8 +91,8 @@ static void doRedirect(JNIEnv *env) {
printf("\ndoRedirect: overwriting the function GetVersion() ...\n");
redir_jni_functions->GetVersion = MyGetVersion;
if ((err = jvmti->SetJNIFunctionTable(redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get new JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -108,8 +108,8 @@ static void doRestore(JNIEnv *env) {
if (verbose)
printf("\ndoRestore: restoring the original JNI function table ...\n");
if ((err = jvmti->SetJNIFunctionTable(orig_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to restore original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -126,8 +126,8 @@ static void checkRedir(JNIEnv *env, int exCalls) {
redir_calls = 0;
if ((err = jvmti->GetJNIFunctionTable(&tested_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&tested_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get modified JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));

View File

@ -46,9 +46,8 @@ void redirect(JNIEnv *env, jvmtiError exError) {
printf("\ntrying to get the JNI function table expecting the error %s to be returned ...\n",
TranslateError(exError));
if ((err = jvmti->GetJNIFunctionTable(
(exError==JVMTI_ERROR_NULL_POINTER)?NULL:&orig_jni_functions)) !=
exError) {
err = jvmti->GetJNIFunctionTable((exError == JVMTI_ERROR_NULL_POINTER) ? NULL : &orig_jni_functions);
if (err != exError) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: GetJNIFunctionTable() returns %s instead of %s as expected\n",
__FILE__, __LINE__, TranslateError(err), TranslateError(exError));
@ -80,7 +79,8 @@ Java_nsk_jvmti_GetJNIFunctionTable_getjniftab002_check(JNIEnv *env, jobject obj)
only since JDK 1.2 */
if (verbose)
printf("\nb) Checking the function with the detached thread ...\n\ndetaching the main thread ...\n");
if ((err = vm->DetachCurrentThread()) != 0) {
err = vm->DetachCurrentThread();
if (err != 0) {
printf(
"(%s,%d): Warning: DetachCurrentThread() returns: %d\n"
"\tcheck with the detached main thread skipped\n",
@ -90,7 +90,8 @@ Java_nsk_jvmti_GetJNIFunctionTable_getjniftab002_check(JNIEnv *env, jobject obj)
if (verbose)
printf("\nattaching the main thread back ...\n");
if ((err = vm->AttachCurrentThread((void **) &nextEnv, (void *) 0)) != 0) {
err = vm->AttachCurrentThread((void **) &nextEnv, (void *) 0);
if (err != 0) {
printf("(%s,%d): TEST FAILURE: waitingThread: AttachCurrentThread() returns: %d\n",
__FILE__, __LINE__, err);
return STATUS_FAILED;

View File

@ -122,7 +122,8 @@ JNIEXPORT void JNICALL
Java_nsk_jvmti_GetOwnedMonitorInfo_ownmoninf001_checkMon1(JNIEnv *env,
jclass cls, jint point, jthread thr, jobject lock) {
jobject *monitors;
if ((monitors = getInfo(env, point, thr, 1)) == NULL) {
monitors = getInfo(env, point, thr, 1);
if (monitors == NULL) {
return;
}
if (!env->IsSameObject(lock, monitors[0])) {
@ -135,7 +136,8 @@ JNIEXPORT void JNICALL
Java_nsk_jvmti_GetOwnedMonitorInfo_ownmoninf001_checkMon2(JNIEnv *env,
jclass cls, jint point, jthread thr, jobject lock1, jobject lock2) {
jobject *monitors;
if ((monitors = getInfo(env, point, thr, 2)) == NULL) {
monitors = getInfo(env, point, thr, 2);
if (monitors == NULL) {
return;
}
if (!env->IsSameObject(lock1, monitors[0]) && !env->IsSameObject(lock2, monitors[0])) {

View File

@ -144,10 +144,19 @@ Java_nsk_jvmti_GetThreadState_thrstat005_checkThreadState(JNIEnv * pEnv, jclass
printf("checkThreadState: wait %d ms\n", waitTime);
fflush(stdout);
if ((res = g_ppJvmtiEnv->RawMonitorEnter(g_waitMon)) != JVMTI_ERROR_NONE
|| (res = g_ppJvmtiEnv->RawMonitorWait(g_waitMon, waitTime)) != JVMTI_ERROR_NONE
|| (res = g_ppJvmtiEnv->RawMonitorExit(g_waitMon)) != JVMTI_ERROR_NONE) {
reportError("GetThreadState: unexpected error", res);
res = g_ppJvmtiEnv->RawMonitorEnter(g_waitMon);
if (res != JVMTI_ERROR_NONE) {
reportError("GetThreadState: unexpected error from RawMontiorEnter", res);
return JNI_FALSE;
}
res = g_ppJvmtiEnv->RawMonitorWait(g_waitMon, waitTime);
if (res != JVMTI_ERROR_NONE) {
reportError("GetThreadState: unexpected error from RawMontiorWait", res);
return JNI_FALSE;
}
res = g_ppJvmtiEnv->RawMonitorExit(g_waitMon);
if (res != JVMTI_ERROR_NONE) {
reportError("GetThreadState: unexpected error from RawMonitorExit", res);
return JNI_FALSE;
}

View File

@ -87,7 +87,8 @@ Java_nsk_jvmti_PopFrame_popframe001_suspThread(JNIEnv *env,
if (vrb == 1)
printf(">>>>>>>> Invoke SuspendThread()\n");
if ((err = (jvmti->SuspendThread(susThr))) != JVMTI_ERROR_NONE) {
err = jvmti->SuspendThread(susThr);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call SuspendThread(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
return JNI_ERR;
@ -108,7 +109,8 @@ Java_nsk_jvmti_PopFrame_popframe001_resThread(JNIEnv *env,
if (vrb == 1)
printf(">>>>>>>> Invoke ResumeThread()\n");
if ((err = (jvmti->ResumeThread(susThr))) != JVMTI_ERROR_NONE) {
err = jvmti->ResumeThread(susThr);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call ResumeThread(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
return JNI_ERR;
@ -147,7 +149,8 @@ Java_nsk_jvmti_PopFrame_popframe001_doPopFrame(JNIEnv *env,
printf(">>>>>>>> Invoke PopFrame()\n");
set_watch_ev(1); /* watch JVMTI events */
if ((err = (jvmti->PopFrame(frameThr))) != JVMTI_ERROR_NONE) {
err = jvmti->PopFrame(frameThr);
if (err != JVMTI_ERROR_NONE) {
printf("TEST FAILED: the function PopFrame() returned the error %d: %s\n",
err, TranslateError(err));
printf("\tFor more info about this error see the JVMTI spec.\n");

View File

@ -87,7 +87,8 @@ Java_nsk_jvmti_PopFrame_popframe003_suspThread(JNIEnv *env,
if (vrb == 1)
printf(">>>>>>>> Invoke SuspendThread()\n");
if ((err = (jvmti->SuspendThread(susThr))) != JVMTI_ERROR_NONE) {
err = jvmti->SuspendThread(susThr);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call SuspendThread(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
return JNI_ERR;
@ -108,7 +109,8 @@ Java_nsk_jvmti_PopFrame_popframe003_resThread(JNIEnv *env, jclass cls, jint vrb,
if (vrb == 1)
printf(">>>>>>>> Invoke ResumeThread()\n");
if ((err = (jvmti->ResumeThread(susThr))) != JVMTI_ERROR_NONE) {
err = jvmti->ResumeThread(susThr);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call ResumeThread(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
return JNI_ERR;
@ -148,7 +150,8 @@ Java_nsk_jvmti_PopFrame_popframe003_doPopFrame(JNIEnv *env, jclass cls, jint vrb
printf(">>>>>>>> Invoke PopFrame()\n");
set_watch_ev(1); /* watch JVMTI events */
if ((err = (jvmti->PopFrame(frameThr))) != JVMTI_ERROR_NONE) {
err = jvmti->PopFrame(frameThr);
if (err != JVMTI_ERROR_NONE) {
printf("TEST FAILED: the function PopFrame() returned the error %d: %s\n",
err, TranslateError(err));
printf("\tFor more info about this error see the JVMTI spec.\n");

View File

@ -88,7 +88,8 @@ int suspThread(jint vrb, jobject susThr) {
printf(">>>>>>>> Invoke SuspendThread()\n");
fflush(stdout);
}
if ((err = (jvmti->SuspendThread(susThr))) != JVMTI_ERROR_NONE) {
err = jvmti->SuspendThread(susThr);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call SuspendThread(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
return JNI_ERR;
@ -111,7 +112,8 @@ int resThread(jint vrb, jobject susThr) {
printf(">>>>>>>> Invoke ResumeThread()\n");
fflush(stdout);
}
if ((err = (jvmti->ResumeThread(susThr))) != JVMTI_ERROR_NONE) {
err = jvmti->ResumeThread(susThr);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call ResumeThread(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
return JNI_ERR;
@ -160,7 +162,8 @@ Java_nsk_jvmti_PopFrame_popframe004_doPopFrame(JNIEnv *env, jclass cls, jint t_c
}
set_watch_ev(1); /* watch JVMTI events */
if ((err = (jvmti->PopFrame(frameThr))) == JVMTI_ERROR_NONE) {
err = jvmti->PopFrame(frameThr);
if (err == JVMTI_ERROR_NONE) {
printf("Check #%d FAILED: PopFrame() was unexpectedly done\n", t_case);
tot_result = STATUS_FAILED;
} else if (err != JVMTI_ERROR_NO_MORE_FRAMES &&
@ -278,7 +281,8 @@ void nativeMeth2(JNIEnv *env, jobject obj, jint vrb,
jclass cls = env->GetObjectClass(frameThr);
jmethodID mid = NULL;
if ((mid = env->GetMethodID(cls, "activeMethod", "()V")) == NULL) {
mid = env->GetMethodID(cls, "activeMethod", "()V");
if (mid == NULL) {
printf("TEST FAILURE: nativeMeth2(): Unable to get method ID\n");
tot_result = STATUS_FAILED;
return;

View File

@ -40,7 +40,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
jint res;
jvmtiError err;
if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK) {
printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
return JNI_ERR;
}

View File

@ -51,7 +51,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
jint res;
jvmtiError err;
if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK) {
printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
return JNI_ERR;
}

View File

@ -51,7 +51,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
jint res;
jvmtiError err;
if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK) {
printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
return JNI_ERR;
}
@ -95,7 +96,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass002_suspThread(JNIEnv *env, jclass cls,
if (vrb == 1)
printf(">>>>>>>> Invoke SuspendThread()\n");
if ((err = (jvmti->SuspendThread(susThr))) != JVMTI_ERROR_NONE) {
err = jvmti->SuspendThread(susThr);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call SuspendThread():\n\tthe function returned error %d: %s\n",
__FILE__, err, TranslateError(err));
printf("\tFor more info about this error see the JVMTI spec.\n");
@ -113,7 +115,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass002_resThread(JNIEnv *env, jclass cls,
if (vrb == 1)
printf(">>>>>>>> Invoke ResumeThread()\n");
if ((err = (jvmti->ResumeThread(susThr))) != JVMTI_ERROR_NONE) {
err = jvmti->ResumeThread(susThr);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call ResumThread():\n\tthe function returned error %d: %s\n",
__FILE__, err, TranslateError(err));
printf("\tFor more info about this error see the JVMTI spec.\n");
@ -147,7 +150,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass002_makeRedefinition(JNIEnv *env, jclas
if (vrb == 1)
printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
classDef.class_byte_count);
if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) {
err = jvmti->RedefineClasses(1, &classDef);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call RedefineClasses():\n\tthe function returned error %d: %s\n",
__FILE__, err, TranslateError(err));
printf("\tFor more info about this error see the JVMTI spec.\n");

View File

@ -53,7 +53,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
jint res;
jvmtiError err;
if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK) {
printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
return JNI_ERR;
}
@ -110,7 +111,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass003_makeRedefinition(JNIEnv *env, jclas
if (vrb == 1)
printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
classDef.class_byte_count);
if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) {
err = jvmti->RedefineClasses(1, &classDef);
if (err != JVMTI_ERROR_NONE) {
if (err == JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED) {
printf("Warning: unrestrictedly redefinition of classes is not implemented,\n"
"\tso the test has no results.\n");
@ -137,14 +139,16 @@ Java_nsk_jvmti_RedefineClasses_redefclass003_checkNewFields(JNIEnv *env,
jint intFld;
jlong longFld;
if ((fid = env->GetStaticFieldID(redefCls, "intComplNewFld", "I")) == NULL) {
fid = env->GetStaticFieldID(redefCls, "intComplNewFld", "I");
if (fid == NULL) {
printf("%s: Failed to get the field ID for the static field \"intComplNewFld\"\n",
__FILE__);
return STATUS_FAILED;
}
intFld = env->GetStaticIntField(redefCls, fid);
if ((fid = env->GetStaticFieldID(redefCls, "longComplNewFld", "J")) == NULL) {
fid = env->GetStaticFieldID(redefCls, "longComplNewFld", "J");
if (fid == NULL) {
printf("%s: Failed to get the field ID for the static field \"longComplNewFld\"\n",
__FILE__);
return STATUS_FAILED;

View File

@ -58,7 +58,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
jint res;
jvmtiError err;
if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK) {
printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
return JNI_ERR;
}
@ -115,7 +116,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass004_makeRedefinition(JNIEnv *env,
if (vrb == 1)
printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
classDef.class_byte_count);
if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) {
err = jvmti->RedefineClasses(1, &classDef);
if (err != JVMTI_ERROR_NONE) {
if (err == JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED) {
printf(
"Warning: unrestrictedly redefinition of classes is not implemented,\n"
@ -147,7 +149,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass004_checkNewFields(JNIEnv *env,
const char *strFld = NULL;
/* get value of new instance field "intComplNewFld" */
if ((fid = env->GetFieldID(redefCls, "intComplNewFld", "I")) == NULL) {
fid = env->GetFieldID(redefCls, "intComplNewFld", "I");
if (fid == NULL) {
printf("%s: Failed to get the field ID for the field \"intComplNewFld\"\n",
__FILE__);
return STATUS_FAILED;
@ -155,7 +158,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass004_checkNewFields(JNIEnv *env,
intFld = env->GetIntField(redefObj, fid);
/* get value of new instance field "longComplNewFld" */
if ((fid = env->GetFieldID(redefCls, "longComplNewFld", "J")) == NULL) {
fid = env->GetFieldID(redefCls, "longComplNewFld", "J");
if (fid == NULL) {
printf("%s: Failed to get the field ID for the field \"longComplNewFld\"\n",
__FILE__);
return STATUS_FAILED;
@ -163,7 +167,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass004_checkNewFields(JNIEnv *env,
longFld = env->GetLongField(redefObj, fid);
/* get value of new instance field "stringComplNewFld" */
if ((fid = env->GetFieldID(redefCls, "stringComplNewFld", "Ljava/lang/String;")) == NULL) {
fid = env->GetFieldID(redefCls, "stringComplNewFld", "Ljava/lang/String;");
if (fid == NULL) {
printf("%s: Failed to get the field ID for the field \"stringComplNewFld\"\n",
__FILE__);
return STATUS_FAILED;

View File

@ -106,7 +106,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
jint res;
jvmtiError err;
if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK) {
printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
return JNI_ERR;
}
@ -172,26 +173,27 @@ Java_nsk_jvmti_RedefineClasses_redefclass005_makeRedefinition(JNIEnv *env,
return PASSED;
}
if ((err = (jvmti->GetCurrentThread(&thread))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCurrentThread(&thread);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to get current thread: %s (%d)\n", TranslateError(err), err);
result = STATUS_FAILED;
return STATUS_FAILED;
}
if ((err = (jvmti->SetEventNotificationMode(JVMTI_ENABLE,
JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) != JVMTI_ERROR_NONE) {
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to enable event JVMTI_EVENT_CLASS_FILE_LOAD_HOOK: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
}
if ((err = (jvmti->SetEventNotificationMode(JVMTI_ENABLE,
JVMTI_EVENT_CLASS_LOAD, thread))) != JVMTI_ERROR_NONE) {
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, thread);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to enable event JVMTI_EVENT_CLASS_LOAD: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
}
if ((err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
JVMTI_EVENT_CLASS_PREPARE, thread)) != JVMTI_ERROR_NONE) {
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, thread);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to enable JVMTI_EVENT_CLASS_PREPARE: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
@ -207,7 +209,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass005_makeRedefinition(JNIEnv *env,
if (vrb == 1)
printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
classDef.class_byte_count);
if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) {
err = jvmti->RedefineClasses(1, &classDef);
if (err != JVMTI_ERROR_NONE) {
printf("TEST FAILED: the function RedefineClasses() returned error %d: %s\n",
err, TranslateError(err));
printf("\tFor more info about this error see the JVMTI spec.\n");

View File

@ -51,7 +51,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
jint res;
jvmtiError err;
if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK) {
printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
return JNI_ERR;
}
@ -125,7 +126,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass006_makeRedefinition(JNIEnv *env,
}
/* explode the bomb */
if ((err = (jvmti->RedefineClasses(1, classDefPtr))) != JVMTI_ERROR_NULL_POINTER) {
err = jvmti->RedefineClasses(1, classDefPtr);
if (err != JVMTI_ERROR_NULL_POINTER) {
printf("TEST FAILED: the function RedefineClasses() returned error %d: %s\n",
err, TranslateError(err));
printf("\tBut it should return the error JVMTI_ERROR_NULL_POINTER.\n");

View File

@ -77,7 +77,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
jint res;
jvmtiError err;
if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK) {
printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
return JNI_ERR;
}
@ -166,15 +167,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass008_setBreakpoints(JNIEnv *env,
breakpoints[i].m_name, breakpoints[i].m_sign, breakpoints[i].loc);
}
if ((err = (jvmti->SetBreakpoint(breakpoints[i].mid,
breakpoints[i].loc))) != JVMTI_ERROR_NONE) {
err = jvmti->SetBreakpoint(breakpoints[i].mid, breakpoints[i].loc);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call SetBreakpoint(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
return STATUS_FAILED;
}
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
JVMTI_EVENT_BREAKPOINT, NULL);
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to enable BREAKPOINT event: %s (%d)\n",
TranslateError(err), err);
@ -210,7 +210,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass008_makeRedefinition(JNIEnv *env,
if (vrb == 1)
printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
classDef.class_byte_count);
if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) {
err = jvmti->RedefineClasses(1, &classDef);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call RedefineClasses(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
printf("\tFor more info about this error see the JVMTI spec.\n");
@ -261,8 +262,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass008_getResult(JNIEnv *env,
}
}
if ((err = (jvmti->ClearBreakpoint(breakpoints[i].mid,
breakpoints[i].loc))) != JVMTI_ERROR_NOT_FOUND) {
err = jvmti->ClearBreakpoint(breakpoints[i].mid, breakpoints[i].loc);
if (err != JVMTI_ERROR_NOT_FOUND) {
printf(
"TEST FAILED: Breakpoint #%d in the %s method:\n"
"\tname=\"%s\"; signature=\"%s\"; location=%d was not cleared:\n"
@ -282,8 +283,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass008_getResult(JNIEnv *env,
breakpoints[i].loc, err, TranslateError(err));
}
if ((err = (jvmti->SetBreakpoint(breakpoints[i].mid,
breakpoints[i].loc))) == JVMTI_ERROR_DUPLICATE) {
err = jvmti->SetBreakpoint(breakpoints[i].mid, breakpoints[i].loc);
if (err == JVMTI_ERROR_DUPLICATE) {
printf(
"TEST FAILED: the function SetBreakpoint() returned the error %d: %s\n"
"\ti.e. the breakpoint #%d has not been really cleared.\n\n",

View File

@ -114,7 +114,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
jint res;
jvmtiError err;
if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK) {
printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
return JNI_ERR;
}
@ -181,8 +182,8 @@ int checkAttr(JNIEnv *env, jclass redefCls, methInfo methodsInfo[],
}
/* get the LocalVariableTable attribute */
if ((err = (jvmti->GetLocalVariableTable(methodsInfo[i].mid,
&count, &lv_table))) != JVMTI_ERROR_NONE) {
err = jvmti->GetLocalVariableTable(methodsInfo[i].mid, &count, &lv_table);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call GetLocalVariableTable(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
printf("\tfor the%s%s method \"%s\", signature \"%s\"\n\n",
@ -266,7 +267,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass009_makeRedefinition(JNIEnv *env,
if (vrb)
printf("\n>>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
classDef.class_byte_count);
if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) {
err = jvmti->RedefineClasses(1, &classDef);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call RedefineClasses(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
printf("\tFor more info about this error see the JVMTI spec.\n");

View File

@ -93,7 +93,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
jint res;
jvmtiError err;
if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK) {
printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
return JNI_ERR;
}
@ -159,8 +160,8 @@ int checkAttr(JNIEnv *env, jclass redefCls, methInfo methodsInfo[], jint vrb) {
}
/* get the LineNumberTable attribute */
if ((err = (jvmti->GetLineNumberTable(methodsInfo[i].mid,
&count, &ln_table))) != JVMTI_ERROR_NONE) {
err = jvmti->GetLineNumberTable(methodsInfo[i].mid, &count, &ln_table);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call GetLineNumberTable(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
printf("\tfor the%s%s method \"%s\", signature \"%s\"\n\n",
@ -241,7 +242,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass010_makeRedefinition(JNIEnv *env,
if (vrb)
printf("\n>>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
classDef.class_byte_count);
if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) {
err = jvmti->RedefineClasses(1, &classDef);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call RedefineClasses(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
printf("\tFor more info about this error see the JVMTI spec.\n");

View File

@ -102,7 +102,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass014_check(JNIEnv *env, jclass cls, jbyt
}
/* to check if RedefineClasses is supported */
if ((err = (jvmti->GetCapabilities(&caps))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCapabilities(&caps);
if (err != JVMTI_ERROR_NONE) {
printf("(GetCapabilities) unexpected error: %s (%d)\n",
TranslateError(err), err);
return STATUS_FAILED;

View File

@ -162,7 +162,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass018_getReady(JNIEnv *env, jclass cls,
classBytes = (jbyteArray) env->NewGlobalRef(bytes);
if ((err = (jvmti->GetCurrentThread(&thread))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCurrentThread(&thread);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to get current thread: %s (%d)\n", TranslateError(err), err);
result = STATUS_FAILED;
return;

View File

@ -77,7 +77,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
jint res;
jvmtiError err;
if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK) {
printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
return JNI_ERR;
}
@ -140,8 +141,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass031_makeRedefinition(JNIEnv *env,
return PASSED;
}
if ((err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
JVMTI_EVENT_NATIVE_METHOD_BIND, NULL)) != JVMTI_ERROR_NONE) {
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to enable JVMTI_EVENT_NATIVE_METHOD_BIND: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
@ -157,7 +158,8 @@ Java_nsk_jvmti_RedefineClasses_redefclass031_makeRedefinition(JNIEnv *env,
if (vrb == 1)
printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
classDef.class_byte_count);
if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) {
err = jvmti->RedefineClasses(1, &classDef);
if (err != JVMTI_ERROR_NONE) {
printf("TEST FAILED: the function RedefineClasses() returned error %d: %s\n",
err, TranslateError(err));
printf("\tFor more info about this error see the JVMTI spec.\n");

View File

@ -76,7 +76,8 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_ERR;
}
if ((err = (jvmti->GetCapabilities(&caps))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCapabilities(&caps);
if (err != JVMTI_ERROR_NONE) {
printf("(GetCapabilities) unexpected error: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;

View File

@ -101,7 +101,8 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_ERR;
}
if ((err = (jvmti->GetCapabilities(&caps))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCapabilities(&caps);
if (err != JVMTI_ERROR_NONE) {
printf("(GetCapabilities) unexpected error: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;

View File

@ -113,7 +113,8 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_ERR;
}
if ((err = (jvmti->GetCapabilities(&caps))) != JVMTI_ERROR_NONE) {
err = jvmti->GetCapabilities(&caps);
if (err != JVMTI_ERROR_NONE) {
printf("(GetCapabilities) unexpected error: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;

View File

@ -70,8 +70,8 @@ static volatile int monent_calls = 0;
static void lock() {
jvmtiError err;
if ((err = jvmti->RawMonitorEnter(countLock)) !=
JVMTI_ERROR_NONE) {
err = jvmti->RawMonitorEnter(countLock);
if (err != JVMTI_ERROR_NONE) {
printf("(%s,%d): TEST FAILURE: RawMonitorEnter returns unexpected error: %s\n",
__FILE__, __LINE__, TranslateError(err));
exit(STATUS_FAILED);
@ -81,8 +81,8 @@ static void lock() {
static void unlock() {
jvmtiError err;
if ((err = jvmti->RawMonitorExit(countLock))
!= JVMTI_ERROR_NONE) {
err = jvmti->RawMonitorExit(countLock);
if (err != JVMTI_ERROR_NONE) {
printf("(%s,%d): TEST FAILURE: RawMonitorExit returns unexpected error: %s\n",
__FILE__, __LINE__, TranslateError(err));
exit(STATUS_FAILED);
@ -116,15 +116,15 @@ void doRedirect(JNIEnv *env) {
if (verbose)
printf("\ndoRedirect: obtaining the JNI function table ...\n");
if ((err = jvmti->GetJNIFunctionTable(&orig_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
env->FatalError("failed to get original JNI function table");
}
if ((err = jvmti->GetJNIFunctionTable(&redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get redirected JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -137,8 +137,8 @@ void doRedirect(JNIEnv *env) {
printf("\ndoRedirect: overwriting the function MonitorEnter ...\n");
redir_jni_functions->MonitorEnter = MyMonitorEnter;
if ((err = jvmti->SetJNIFunctionTable(redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to set new JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -154,8 +154,8 @@ void doRestore(JNIEnv *env) {
if (verbose)
printf("\ndoRestore: restoring the original JNI function table ...\n");
if ((err = jvmti->SetJNIFunctionTable(orig_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to restore original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -168,7 +168,8 @@ void doRestore(JNIEnv *env) {
void doExec(JNIEnv *env, int thrNum) {
jint res;
if ((res = env->MonitorEnter(clsObj)) != 0) {
res = env->MonitorEnter(clsObj);
if (res != 0) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILURE: MonitorEnter() returns %d for thread #%d\n",
__FILE__, __LINE__, res, thrNum);
@ -183,7 +184,8 @@ void doExec(JNIEnv *env, int thrNum) {
if (verbose)
printf("\ndoExec: thread #%d entered the monitor\n",
thrNum);
if ((res = env->MonitorExit(clsObj)) != 0) {
res = env->MonitorExit(clsObj);
if (res != 0) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILURE: MonitorExit() returns %d for thread #%d\n",
__FILE__, __LINE__, res, thrNum);
@ -221,7 +223,8 @@ static int waitingThread(void *context) {
if (verbose)
printf("\nwaitingThread: thread #%d started\n\tattaching the thread to the VM ...\n",
indx);
if ((res = vm->AttachCurrentThread((void **) &env, (void *) 0)) != 0) {
res = vm->AttachCurrentThread((void **) &env, (void *) 0);
if (res != 0) {
printf("(%s,%d): TEST FAILURE: waitingThread: AttachCurrentThread() returns: %d\n",
__FILE__, __LINE__, res);
return STATUS_FAILED;
@ -231,7 +234,8 @@ static int waitingThread(void *context) {
doExec(env, indx);
if ((res = vm->DetachCurrentThread()) != 0) {
res = vm->DetachCurrentThread();
if (res != 0) {
printf("(%s,%d): TEST FAILURE: waitingThread: DetachCurrentThread() returns: %d\n",
__FILE__, __LINE__, res);
return STATUS_FAILED;
@ -252,7 +256,8 @@ static jobject getObjectFromField(JNIEnv *env, jobject obj) {
if (verbose)
printf("\ngetObjectFromField: obtaining field ID for name=\"%s\" signature=\"%s\"...\n",
javaField, classSig);
if ((fid = env->GetFieldID(_objCls, javaField, classSig)) == 0) {
fid = env->GetFieldID(_objCls, javaField, classSig);
if (fid == 0) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILURE: failed to get ID for the field \"%s\"\n",
__FILE__, __LINE__, javaField);
@ -326,7 +331,8 @@ Java_nsk_jvmti_SetJNIFunctionTable_setjniftab001_check(JNIEnv *env, jobject obj)
return STATUS_FAILED;
}
if ((clsObj = env->NewGlobalRef(getObjectFromField(env, obj))) == NULL) {
clsObj = env->NewGlobalRef(getObjectFromField(env, obj));
if (clsObj == NULL) {
printf("(%s,%d): TEST FAILURE: cannot create a new global reference of class \"%s\"\n",
__FILE__, __LINE__, classSig);
env->FatalError("failed to create a new global reference");
@ -351,7 +357,8 @@ Java_nsk_jvmti_SetJNIFunctionTable_setjniftab001_check(JNIEnv *env, jobject obj)
if (verbose)
printf("\nb) Checking the assertion inside main thread detached and attached again ...\n\ndetaching the main thread ...\n");
if ((res = vm->DetachCurrentThread()) != 0) {
res = vm->DetachCurrentThread();
if (res != 0) {
printf(
"(%s,%d): Warning: DetachCurrentThread() returns: %d\n"
"\tcheck with the detached main thread skipped\n",
@ -359,7 +366,8 @@ Java_nsk_jvmti_SetJNIFunctionTable_setjniftab001_check(JNIEnv *env, jobject obj)
} else {
if (verbose)
printf("\nattaching the main thread again ...\n");
if ((res = vm->AttachCurrentThread((void **) &nextEnv, (void *) 0)) != 0) {
res = vm->AttachCurrentThread((void **) &nextEnv, (void *) 0);
if (res != 0) {
printf("(%s,%d): TEST FAILURE: waitingThread: AttachCurrentThread() returns: %d\n",
__FILE__, __LINE__, res);
return STATUS_FAILED;
@ -419,8 +427,8 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
vm = jvm;
if ((err = jvmti->CreateRawMonitor("_counter_lock",
&countLock)) != JVMTI_ERROR_NONE) {
err = jvmti->CreateRawMonitor("_counter_lock", &countLock);
if (err != JVMTI_ERROR_NONE) {
printf("(%s,%d): TEST FAILURE: CreateRawMonitor() returns unexpected error: %s\n",
__FILE__, __LINE__, TranslateError(err));
return JNI_ERR;

View File

@ -45,8 +45,8 @@ void redirect(JNIEnv *env, jvmtiError exError) {
printf("\ntrying to overwrite the JNI function table expecting the error %s to be returned ...\n",
TranslateError(exError));
if ((err = jvmti->SetJNIFunctionTable(NULL)) !=
exError) {
err = jvmti->SetJNIFunctionTable(NULL);
if (err != exError) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: SetJNIFunctionTable() returns %s instead of %s as expected\n",
__FILE__, __LINE__, TranslateError(err), TranslateError(exError));
@ -78,7 +78,8 @@ Java_nsk_jvmti_SetJNIFunctionTable_setjniftab002_check(JNIEnv *env, jobject obj)
only since JDK 1.2 */
if (verbose)
printf("\nb) Checking the function with the detached thread ...\n\ndetaching the main thread ...\n");
if ((res = vm->DetachCurrentThread()) != JNI_OK) {
res = vm->DetachCurrentThread();
if (res != JNI_OK) {
printf(
"(%s,%d): Warning: DetachCurrentThread() returns: %d\n"
"\tcheck with the detached main thread skipped\n",
@ -88,7 +89,8 @@ Java_nsk_jvmti_SetJNIFunctionTable_setjniftab002_check(JNIEnv *env, jobject obj)
if (verbose)
printf("\nattaching the main thread back ...\n");
if ((res = vm->AttachCurrentThread((void **) &nextEnv, (void *) 0)) != JNI_OK) {
res = vm->AttachCurrentThread((void **) &nextEnv, (void *) 0);
if (res != JNI_OK) {
printf("(%s,%d): TEST FAILURE: waitingThread: AttachCurrentThread() returns: %d\n",
__FILE__, __LINE__, res);
return STATUS_FAILED;

View File

@ -108,7 +108,8 @@ MonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv* jni, jthread thr, jobject obj) {
if (jni->IsSameObject(thread, thr) &&
jni->IsSameObject(object_M, obj)) {
if (!(line = findLineNumber(jvmti, thread))) {
line = findLineNumber(jvmti, thread);
if (!line) {
nsk_jvmti_setFailStatus();
NSK_COMPLAIN2("MonitorContendedEnter event: thread=%p, object=%p\n",
thr, obj);
@ -152,7 +153,8 @@ MonitorContendedEntered(jvmtiEnv *jvmti, JNIEnv* jni, jthread thr, jobject obj)
if (jni->IsSameObject(thread, thr) &&
jni->IsSameObject(object_M, obj)) {
if (!(line = findLineNumber(jvmti, thread))) {
line = findLineNumber(jvmti, thread);
if (!line) {
nsk_jvmti_setFailStatus();
NSK_COMPLAIN2("MonitorContendedEntered event: thread=%p, object=%p\n",
thr, obj);

View File

@ -100,7 +100,8 @@ callbackClassPrepare(jvmtiEnv *jvmti_env,
} else {
NSK_COMPLAIN0("\nMyClass :: Failed to redefine ..\n");
}
if ((myTestClass = (jclass) jni_env->NewGlobalRef(klass)) == NULL) {
myTestClass = (jclass) jni_env->NewGlobalRef(klass);
if (myTestClass == NULL) {
NSK_COMPLAIN0("Failed to create global ref...");
}
}

View File

@ -63,16 +63,16 @@ void doRedirect(JNIEnv *env) {
if (verbose)
printf("\ndoRedirect: obtaining the JNI function ...\n");
if ((err = jvmti->GetJNIFunctionTable(&orig_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
printf("(%s,%d): TEST FAILED: failed to get original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
env->FatalError("failed to get original JNI function table");
result = STATUS_FAILED;
}
if ((err = jvmti->GetJNIFunctionTable(&redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
printf("(%s,%d): TEST FAILED: failed to get redirected JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
env->FatalError("failed to get redirected JNI function table");
@ -83,8 +83,8 @@ void doRedirect(JNIEnv *env) {
redir_jni_functions->GetVersion = MyGetVersion;
if ((err = jvmti->SetJNIFunctionTable(redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
printf("(%s,%d): TEST FAILED: failed to set new JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
env->FatalError("failed to set new JNI function table");
@ -100,8 +100,8 @@ void doRestore(JNIEnv *env) {
if (verbose)
printf("\ndoRestore: restoring the original JNI function ...\n");
if ((err = jvmti->SetJNIFunctionTable(orig_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
printf("(%s,%d): TEST FAILED: failed to restore original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
env->FatalError("failed to restore original JNI function table");

View File

@ -98,15 +98,15 @@ void doRedirect(JNIEnv *env, jclass cls) {
if (verbose)
printf("\ndoRedirect: obtaining the JNI function table ...\n");
if ((err = jvmti->GetJNIFunctionTable(&orig_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
env->FatalError("failed to get original JNI function table");
}
if ((err = jvmti->GetJNIFunctionTable(&redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get redirected JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -137,8 +137,8 @@ void doRedirect(JNIEnv *env, jclass cls) {
if (verbose)
printf("\ndoRedirect: obtaining field ID for \"%s\"...\n",
meth_info[i].f_name);
if ((meth_info[i].fid = env->GetStaticFieldID(
cls, meth_info[i].f_name, "I")) == 0) {
meth_info[i].fid = env->GetStaticFieldID(cls, meth_info[i].f_name, "I");
if (meth_info[i].fid == 0) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get ID for the field %s\n",
__FILE__, __LINE__, meth_info[i].f_name);
@ -159,8 +159,8 @@ void doRedirect(JNIEnv *env, jclass cls) {
}
}
if ((err = jvmti->SetJNIFunctionTable(redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to set new JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -176,8 +176,8 @@ void doRestore(JNIEnv *env) {
if (verbose)
printf("\ndoRestore: restoring the original JNI function table ...\n");
if ((err = jvmti->SetJNIFunctionTable(orig_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to restore original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));

View File

@ -103,15 +103,15 @@ void doRedirect(JNIEnv *env) {
if (verbose)
printf("\ndoRedirect: obtaining the JNI function table ...\n");
if ((err = jvmti->GetJNIFunctionTable(&orig_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
env->FatalError("failed to get original JNI function table");
}
if ((err = jvmti->GetJNIFunctionTable(&redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get redirected JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -126,8 +126,8 @@ void doRedirect(JNIEnv *env) {
redir_jni_functions->ThrowNew = MyThrowNew;
redir_jni_functions->ExceptionOccurred = MyExceptionOccurred;
if ((err = jvmti->SetJNIFunctionTable(redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to set new JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -143,8 +143,8 @@ void doRestore(JNIEnv *env) {
if (verbose)
printf("\ndoRestore: restoring the original JNI function table ...\n");
if ((err = jvmti->SetJNIFunctionTable(orig_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to restore original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -157,7 +157,8 @@ void doRestore(JNIEnv *env) {
void doExc(JNIEnv *env, jthrowable thrw, jclass thrCls, const char *msg) {
jint res;
if ((res = env->ThrowNew(thrCls, msg)) != 0) {
res = env->ThrowNew(thrCls, msg);
if (res != 0) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to throw new exception\n",
__FILE__, __LINE__);
@ -176,7 +177,8 @@ void doExc(JNIEnv *env, jthrowable thrw, jclass thrCls, const char *msg) {
__FILE__, __LINE__, msg);
}
if ((res = env->Throw(thrw)) != 0) {
res = env->Throw(thrw);
if (res != 0) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to throw exception\n",
__FILE__, __LINE__);
@ -264,7 +266,8 @@ Java_nsk_jvmti_scenarios_jni_1interception_JI03_ji03t003_check(JNIEnv *env, jobj
if (verbose)
printf("\ncheck: obtaining field ID for \"name=%s signature=%s\"...\n",
javaField, excClassSig);
if ((fid = env->GetFieldID(objCls, javaField, excClassSig)) == 0) {
fid = env->GetFieldID(objCls, javaField, excClassSig);
if (fid == 0) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get ID for the field \"%s\"\n",
__FILE__, __LINE__, javaField);

View File

@ -78,13 +78,15 @@ void doRedirect(JNIEnv *env) {
if (verbose)
printf("\ndoRedirect: obtaining the JNI function table ...\n");
if ((err = jvmti->GetJNIFunctionTable(&orig_jni_functions)) != JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
env->FatalError("failed to get original JNI function table");
}
if ((err = jvmti->GetJNIFunctionTable(&redir_jni_functions)) != JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get redirected JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -98,8 +100,8 @@ void doRedirect(JNIEnv *env) {
redir_jni_functions->AllocObject = MyAllocObject;
redir_jni_functions->NewObjectV = MyNewObjectV;
if ((err = jvmti->SetJNIFunctionTable(redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to set new JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -115,7 +117,8 @@ void doRestore(JNIEnv *env) {
if (verbose)
printf("\ndoRestore: restoring the original JNI function table ...\n");
if ((err = jvmti->SetJNIFunctionTable(orig_jni_functions)) != JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to restore original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
@ -130,8 +133,8 @@ void doExec(JNIEnv *env, jclass allCls, jmethodID ctorId, const char *msg, ...)
jobject newObj;
va_list args;
va_start(args, msg);
if ((allObj = env->AllocObject(allCls))
== NULL) {
allObj = env->AllocObject(allCls);
if (allObj == NULL) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to call %s AllocObject()\n",
__FILE__, __LINE__, msg);
@ -211,14 +214,15 @@ Java_nsk_jvmti_scenarios_jni_1interception_JI03_ji03t004_check(JNIEnv *env, jobj
return STATUS_FAILED;
}
if ((objCls = env->FindClass(classSig)) == NULL) {
objCls = env->FindClass(classSig);
if (objCls == NULL) {
printf("(%s,%d): TEST FAILED: failed to call FindClass() for \"%s\"\n",
__FILE__, __LINE__, classSig);
return STATUS_FAILED;
}
if ((ctorId = env->GetMethodID(objCls, "<init>", "()V"))
== NULL) {
ctorId = env->GetMethodID(objCls, "<init>", "()V");
if (ctorId == NULL) {
printf("(%s,%d): TEST FAILED: failed to call GetMethodID() for a constructor\n",
__FILE__, __LINE__);
return STATUS_FAILED;

View File

@ -99,13 +99,15 @@ static void doRedirect(JNIEnv *env, jvmtiEnv *jvmti, int indx) {
NSK_DISPLAY1("\n%s JVMTI env: doRedirect: obtaining the JNI function table ...\n",
(indx==0)?"first":"second");
if ((err = jvmti->GetJNIFunctionTable(&orig_jni_functions[indx])) != JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&orig_jni_functions[indx]);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
NSK_COMPLAIN2("TEST FAILED: %s JVMTI env: failed to get original JNI function table: %s\n",
(indx==0)?"first":"second", TranslateError(err));
env->FatalError("failed to get original JNI function table");
}
if ((err = jvmti->GetJNIFunctionTable(&redir_jni_functions[indx])) != JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&redir_jni_functions[indx]);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
NSK_COMPLAIN2("TEST FAILED: %s JVMTI env: failed to get redirected JNI function table: %s\n",
(indx==0)?"first":"second", TranslateError(err));
@ -119,7 +121,8 @@ static void doRedirect(JNIEnv *env, jvmtiEnv *jvmti, int indx) {
redir_jni_functions[indx]->GetVersion =
(indx==0)?MyGetVersionA:MyGetVersionB;
if ((err = jvmti->SetJNIFunctionTable(redir_jni_functions[indx])) != JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(redir_jni_functions[indx]);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
NSK_COMPLAIN2("TEST FAILED: %s JVMTI env: failed to set new JNI function table: %s\n",
(indx==0)?"first":"second", TranslateError(err));
@ -194,8 +197,8 @@ static int initAgent(int indx) {
callbacks.VMInit = &VMInitB;
break;
}
if ((err = jvmti[indx]->SetEventCallbacks(
&callbacks, sizeof(callbacks))) != JVMTI_ERROR_NONE) {
err = jvmti[indx]->SetEventCallbacks(&callbacks, sizeof(callbacks));
if (err != JVMTI_ERROR_NONE) {
NSK_COMPLAIN1("TEST FAILURE: failed to set event callbacks: %s\n",
TranslateError(err));
result = STATUS_FAILED;
@ -204,8 +207,8 @@ static int initAgent(int indx) {
NSK_DISPLAY1("\nagent %s initializer: setting event callbacks done\n\tenabling events ...\n",
(indx==0)?"A":"B");
if ((err = jvmti[indx]->SetEventNotificationMode(JVMTI_ENABLE,
JVMTI_EVENT_VM_INIT, NULL)) != JVMTI_ERROR_NONE) { /* enable event globally */
err = jvmti[indx]->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL);
if (err != JVMTI_ERROR_NONE) { /* enable event globally */
NSK_COMPLAIN2("TEST FAILURE: failed to enable JVMTI_EVENT_VM_INIT event for the agent %s: %s\n",
(indx==0)?"A":"B", TranslateError(err));
result = STATUS_FAILED;
@ -255,7 +258,8 @@ static int agentA(void *context) {
int exitCode = PASSED;
NSK_DISPLAY0("\nthe agent A started\n\tattaching the thread to the VM ...\n");
if ((res = vm->AttachCurrentThread((void **) &env, (void *) 0)) != 0) {
res = vm->AttachCurrentThread((void **) &env, (void *) 0);
if (res != 0) {
NSK_COMPLAIN1("TEST FAILURE: AttachCurrentThread() returns: %d\n", res);
exit(STATUS_FAILED);
}
@ -304,7 +308,8 @@ static int agentA(void *context) {
NSK_DISPLAY1("\nagent A: detaching and returning exit code %d\n",
exitCode);
if ((res = vm->DetachCurrentThread()) != 0) {
res = vm->DetachCurrentThread();
if (res != 0) {
NSK_COMPLAIN1("TEST WARNING: agent A: DetachCurrentThread() returns: %d\n", res);
}
return exitCode;
@ -318,7 +323,8 @@ static int agentB(void *context) {
int exitCode = PASSED;
NSK_DISPLAY0("\nthe agent B started\n\tattaching the thread to the VM ...\n");
if ((res = vm->AttachCurrentThread((void **) &env, (void *) 0)) != 0) {
res = vm->AttachCurrentThread((void **) &env, (void *) 0);
if (res != 0) {
NSK_COMPLAIN1("TEST FAILURE: AttachCurrentThread() returns: %d\n",
res);
exit(STATUS_FAILED);
@ -366,7 +372,8 @@ static int agentB(void *context) {
NSK_DISPLAY1("\nagent B: detaching and returning exit code %d\n",
exitCode);
if ((res = vm->DetachCurrentThread()) != 0) {
res = vm->DetachCurrentThread();
if (res != 0) {
NSK_COMPLAIN1("TEST WARNING: agent B: DetachCurrentThread() returns: %d\n", res);
}
return exitCode;

View File

@ -106,7 +106,8 @@ jint JNICALL MyMonitorEnter(JNIEnv *env, jobject obj) {
static jint enterMonitor(JNIEnv *env, const char *thr) {
jint result;
if ((result = env->MonitorEnter(clsObj)) != 0) {
result = env->MonitorEnter(clsObj);
if (result != 0) {
NSK_COMPLAIN2("TEST FAILURE: %s: MonitorEnter() returns: %d\n",
thr, result);
return STATUS_FAILED;
@ -125,7 +126,8 @@ static jint enterMonitor(JNIEnv *env, const char *thr) {
static jint exitMonitor(JNIEnv *env, const char *thr) {
jint result;
if ((result = env->MonitorExit(clsObj)) != 0) {
result = env->MonitorExit(clsObj);
if (result != 0) {
NSK_COMPLAIN2("TEST FAILURE: %s: MonitorExit() returns: %d\n",
thr, result);
return STATUS_FAILED;
@ -138,15 +140,15 @@ static void doRedirect(JNIEnv *env) {
jvmtiError err;
NSK_DISPLAY0("doRedirect: obtaining the JNI function table ...\n");
if ((err = jvmti->GetJNIFunctionTable(&orig_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&orig_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
NSK_COMPLAIN1("TEST FAILED: failed to get original JNI function table: %s\n",
TranslateError(err));
env->FatalError("failed to get original JNI function table");
}
if ((err = jvmti->GetJNIFunctionTable(&redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->GetJNIFunctionTable(&redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
NSK_COMPLAIN1("TEST FAILED: failed to get redirected JNI function table: %s\n",
TranslateError(err));
@ -158,8 +160,8 @@ static void doRedirect(JNIEnv *env) {
redir_jni_functions->MonitorEnter = MyMonitorEnter;
if ((err = jvmti->SetJNIFunctionTable(redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
err = jvmti->SetJNIFunctionTable(redir_jni_functions);
if (err != JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
NSK_COMPLAIN1("TEST FAILED: failed to set new JNI function table: %s\n",
TranslateError(err));
@ -198,7 +200,8 @@ static int waitingThread(void *context) {
"waitingThread: thread #%d started\n"
"\tattaching the thread to the VM ...\n",
indx);
if ((res = vm->AttachCurrentThread((void **) &env, (void *) 0)) != 0) {
res = vm->AttachCurrentThread((void **) &env, (void *) 0);
if (res != 0) {
NSK_COMPLAIN1("TEST FAILURE: waitingThread: AttachCurrentThread() returns: %d\n",
res);
return STATUS_FAILED;
@ -229,7 +232,8 @@ static int ownerThread(void *context) {
int tries = 0;
NSK_DISPLAY0("ownerThread: thread started\n\tattaching the thread to the VM ...\n");
if ((res = vm->AttachCurrentThread((void **) &env, (void *) 0)) != 0) {
res = vm->AttachCurrentThread((void **) &env, (void *) 0);
if (res != 0) {
NSK_COMPLAIN1("TEST FAILURE: ownerThread: AttachCurrentThread() returns: %d\n",
res);
return STATUS_FAILED;
@ -270,7 +274,8 @@ static int redirectorThread(void *context) {
int tries = 0;
NSK_DISPLAY0("redirectorThread: thread started\n\tattaching the thread to the VM ...\n");
if ((res = vm->AttachCurrentThread((void **) &env, (void *) 0)) != 0) {
res = vm->AttachCurrentThread((void **) &env, (void *) 0);
if (res != 0) {
NSK_COMPLAIN1("TEST FAILURE: redirectorThread: AttachCurrentThread() returns: %d\n",
res);
return STATUS_FAILED;
@ -294,7 +299,8 @@ static jobject getObjectFromField(JNIEnv *env, jobject obj) {
NSK_DISPLAY2("getObjectFromField: obtaining field ID for name=\"%s\" signature=\"%s\"...\n",
javaField, classSig);
if ((fid = env->GetFieldID(_objCls, javaField, classSig)) == 0) {
fid = env->GetFieldID(_objCls, javaField, classSig);
if (fid == 0) {
result = STATUS_FAILED;
NSK_COMPLAIN1("TEST FAILURE: failed to get ID for the field \"%s\"\n",
javaField);
@ -322,7 +328,8 @@ Java_nsk_jvmti_scenarios_jni_1interception_JI06_ji06t001_check(JNIEnv *env, jobj
}
/* prepare the testing */
if ((clsObj = env->NewGlobalRef(getObjectFromField(env, obj))) == NULL) {
clsObj = env->NewGlobalRef(getObjectFromField(env, obj));
if (clsObj == NULL) {
NSK_COMPLAIN1("TEST FAILURE: cannot create a new global reference of class \"%s\"\n",
classSig);
env->FatalError("failed to create a new global reference");

View File

@ -85,8 +85,8 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretbase_suspThread(JNIEnv *env,
}
printf(">>>>>>>> Invoke SuspendThread()\n");
if ((err = (jvmti->SuspendThread(earlyretThr)))
!= JVMTI_ERROR_NONE) {
err = jvmti->SuspendThread(earlyretThr);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call SuspendThread(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
return JNI_ERR;
@ -106,8 +106,8 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretbase_resThread(JNIEnv *env,
}
printf(">>>>>>>> Invoke ResumeThread()\n");
if ((err = (jvmti->ResumeThread(earlyretThr)))
!= JVMTI_ERROR_NONE) {
err = jvmti->ResumeThread(earlyretThr);
if (err != JVMTI_ERROR_NONE) {
printf("%s: Failed to call ResumeThread(): error=%d: %s\n",
__FILE__, err, TranslateError(err));
return JNI_ERR;
@ -168,8 +168,8 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretbase_doForceEarlyReturn(JNIEnv *env
}
printf("After call to GetMethodID(%s, %s)\n", name_exp, sig_exp);
if ((err = (jvmti->ForceEarlyReturnLong(earlyretThr, valToRet)))
!= JVMTI_ERROR_NONE) {
err = jvmti->ForceEarlyReturnLong(earlyretThr, valToRet);
if (err != JVMTI_ERROR_NONE) {
printf("TEST FAILED: the function ForceEarlyReturn()"
" returned the error %d: %s\n",
err, TranslateError(err));

View File

@ -110,7 +110,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
printdump = JNI_TRUE;
}
if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK) {
printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
return JNI_ERR;
}
@ -149,15 +150,15 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
return JNI_ERR;
}
if ((err = (jvmti->SetEventNotificationMode(JVMTI_ENABLE,
JVMTI_EVENT_VM_INIT, NULL))) != JVMTI_ERROR_NONE) {
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to enable event JVMTI_EVENT_VM_INIT: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;
}
if ((err = (jvmti->SetEventNotificationMode(JVMTI_ENABLE,
JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) != JVMTI_ERROR_NONE) {
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL);
if (err != JVMTI_ERROR_NONE) {
printf("Failed to enable event JVMTI_EVENT_CLASS_FILE_LOAD_HOOK: %s (%d)\n",
TranslateError(err), err);
return JNI_ERR;

View File

@ -581,8 +581,8 @@ static jint allocClsInfo(JNIEnv *jni_env, char *cls_sig, jclass clazz) {
jbyteArray classBytes;
jboolean isCopy;
if ((_clsInfo = (class_info*)
malloc(sizeof(class_info))) == NULL)
_clsInfo = (class_info*) malloc(sizeof(class_info));
if (_clsInfo == NULL)
jni_env->FatalError("JVMTIagent: cannot allocate memory for class_info\n");
/* fill the structure class_info */

View File

@ -237,7 +237,8 @@ JNIEXPORT jboolean JNICALL Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects
return JNI_FALSE;
}
if ((pRefRec = findRefToVerify(tagFrom, tagTo, refKind)) != NULL) {
pRefRec = findRefToVerify(tagFrom, tagTo, refKind);
if (pRefRec != NULL) {
pRefRec->_expectedCount += count;
return JNI_TRUE;
}
@ -249,7 +250,8 @@ jboolean markRefToVerify(jlong tagFrom, jlong tagTo, int refKind)
{
RefToVerify * pRefRec;
if ((pRefRec = findRefToVerify(tagFrom, tagTo, refKind)) != NULL) {
pRefRec = findRefToVerify(tagFrom, tagTo, refKind);
if (pRefRec != NULL) {
pRefRec->_actualCount++;
return JNI_TRUE;
}

View File

@ -41,7 +41,8 @@ JNI_OnLoad(JavaVM *vm, void *reserved)
}
FIND_CLASS(stackOverflowErrorClass, "java/lang/StackOverflowError");
if ((stackOverflowErrorClass = (jclass) env->NewGlobalRef(stackOverflowErrorClass)) == NULL) {
stackOverflowErrorClass = (jclass) env->NewGlobalRef(stackOverflowErrorClass);
if (stackOverflowErrorClass == NULL) {
printf("Can't create global ref for stack overflow class\n");
return 0;
}

View File

@ -43,7 +43,8 @@ JNI_OnLoad(JavaVM *vm, void *reserved)
}
FIND_CLASS(stackOverflowErrorClass, "java/lang/StackOverflowError");
if ((stackOverflowErrorClass = (jclass) env->NewGlobalRef(stackOverflowErrorClass)) == NULL) {
stackOverflowErrorClass = (jclass) env->NewGlobalRef(stackOverflowErrorClass);
if (stackOverflowErrorClass == NULL) {
printf("Can't create global ref for stack overflow class\n");
return 0;
}

View File

@ -147,7 +147,8 @@ jboolean doDumpCore() {
static const char* name = "DBGHELP.DLL";
printf("# TEST: creating Windows minidump...\n");
if ((size = GetSystemDirectory(path, pathLen)) > 0) {
size = GetSystemDirectory(path, pathLen);
if (size > 0) {
strcat(path, "\\");
strcat(path, name);
dbghelp = LoadLibrary(path);
@ -158,12 +159,15 @@ jboolean doDumpCore() {
}
// try Windows directory
if (dbghelp == NULL && ((size = GetWindowsDirectory(path, pathLen)) > 6)) {
strcat(path, "\\");
strcat(path, name);
dbghelp = LoadLibrary(path);
if (dbghelp == NULL) {
reportLastError("Load DBGHELP.DLL from Windows directory");
if (dbghelp == NULL) {
size = GetWindowsDirectory(path, pathLen);
if (size > 6) {
strcat(path, "\\");
strcat(path, name);
dbghelp = LoadLibrary(path);
if (dbghelp == NULL) {
reportLastError("Load DBGHELP.DLL from Windows directory");
}
}
}
if (dbghelp == NULL) {