8215425: vmTestbase/nsk/jvmti/PopFrame should provide more detailed output
Reviewed-by: sspitsyn, jcbeyler
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe001.java Wed Dec 19 20:53:30 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe001.java Wed Dec 19 14:08:08 2018 -0800
@@ -39,7 +39,6 @@
static final int FAILED = 2;
static final int JCK_STATUS_BASE = 95;
- static boolean DEBUG_MODE = false;
static volatile boolean popFdone = false;
static volatile int totRes = PASSED;
private PrintStream out;
@@ -58,9 +57,9 @@
}
}
- native static int doPopFrame(int vrb, popFrameCls popFrameClsThr);
- native static int suspThread(int vrb, popFrameCls popFrameClsThr);
- native static int resThread(int vrb, popFrameCls popFrameClsThr);
+ native static int doPopFrame(popFrameCls popFrameClsThr);
+ native static int suspThread(popFrameCls popFrameClsThr);
+ native static int resThread(popFrameCls popFrameClsThr);
public static void main(String[] argv) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
@@ -76,10 +75,6 @@
int retValue = 0;
this.out = out;
- for (int i = 0; i < argv.length; i++) {
- if (argv[i].equals("-v")) // verbose mode
- DEBUG_MODE = true;
- }
popFrameClsThr = new popFrameCls("Tested Thread");
startingBarrier = new Wicket();
@@ -90,35 +85,26 @@
synchronized (barrier) {
}
- if (DEBUG_MODE) {
- out.println("Going to suspend the thread...");
- retValue = suspThread(1, popFrameClsThr);
- } else
- retValue = suspThread(0, popFrameClsThr);
+ out.println("Going to suspend the thread...");
+ retValue = suspThread(popFrameClsThr);
if (retValue != PASSED) {
out.println("TEST: failed to suspend thread");
return FAILED;
}
// pop a frame of the child thread
- if (DEBUG_MODE) {
- out.println("Going to pop a frame...");
- retValue = doPopFrame(1, popFrameClsThr);
- } else
- retValue = doPopFrame(0, popFrameClsThr);
+ out.println("Going to pop a frame...");
+ retValue = doPopFrame(popFrameClsThr);
popFdone = true;
popFrameClsThr.letItGo();
if (retValue != PASSED) {
out.println("TEST: failed to pop frame");
- resThread(0, popFrameClsThr);
+ resThread(popFrameClsThr);
return FAILED;
}
- if (DEBUG_MODE) {
- out.println("Going to resume the thread...");
- retValue = resThread(1, popFrameClsThr);
- } else
- retValue = resThread(0, popFrameClsThr);
+ out.println("Going to resume the thread...");
+ retValue = resThread(popFrameClsThr);
if (retValue != PASSED) {
out.println("TEST: failed to resume thread");
return FAILED;
@@ -143,30 +129,22 @@
public void run() {
activeMethod();
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): exiting...");
+ out.println("popFrameCls (" + this + "): exiting...");
}
public void activeMethod() {
boolean compl = true; // complain in a finally block
if (popframe001.popFdone) { // popping has been done
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): enter activeMethod() after popping");
+ out.println("popFrameCls (" + this + "): enter activeMethod() after popping");
return;
}
try {
// notify the main thread
synchronized (popframe001.barrier) {
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): notifying main thread");
+ out.println("popFrameCls (" + this + "): notifying main thread");
popframe001.startingBarrier.unlock();
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): inside activeMethod()");
+ out.println("popFrameCls (" + this + "): inside activeMethod()");
}
// loop until the main thread pops us
int i = 0;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe001/popframe001.cpp Wed Dec 19 20:53:30 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe001/popframe001.cpp Wed Dec 19 14:08:08 2018 -0800
@@ -77,52 +77,41 @@
}
JNIEXPORT jint JNICALL
-Java_nsk_jvmti_PopFrame_popframe001_suspThread(JNIEnv *env,
- jclass cls, jint vrb, jobject susThr) {
- jvmtiError err;
-
+Java_nsk_jvmti_PopFrame_popframe001_suspThread(JNIEnv *env, jclass cls, jobject susThr) {
if (!caps.can_pop_frame || !caps.can_suspend) {
return PASSED;
}
- if (vrb == 1)
- printf(">>>>>>>> Invoke SuspendThread()\n");
- err = jvmti->SuspendThread(susThr);
+ printf(">>>>>>>> Invoke SuspendThread()\n");
+ jvmtiError 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;
}
- if (vrb == 1)
- printf("<<<<<<<< SuspendThread() is successfully done\n");
+ printf("<<<<<<<< SuspendThread() is successfully done\n");
return PASSED;
}
JNIEXPORT jint JNICALL
-Java_nsk_jvmti_PopFrame_popframe001_resThread(JNIEnv *env,
- jclass cls, jint vrb, jobject susThr) {
- jvmtiError err;
-
+Java_nsk_jvmti_PopFrame_popframe001_resThread(JNIEnv *env, jclass cls, jobject susThr) {
if (!caps.can_pop_frame || !caps.can_suspend) {
return PASSED;
}
- if (vrb == 1)
- printf(">>>>>>>> Invoke ResumeThread()\n");
- err = jvmti->ResumeThread(susThr);
+ printf(">>>>>>>> Invoke ResumeThread()\n");
+ jvmtiError 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;
}
- if (vrb == 1)
- printf("<<<<<<<< ResumeThread() is successfully done\n");
+ printf("<<<<<<<< ResumeThread() is successfully done\n");
return PASSED;
}
JNIEXPORT jint JNICALL
-Java_nsk_jvmti_PopFrame_popframe001_doPopFrame(JNIEnv *env,
- jclass cls, jint vrb, jobject frameThr) {
+Java_nsk_jvmti_PopFrame_popframe001_doPopFrame(JNIEnv *env, jclass cls, jobject frameThr) {
jvmtiError err;
if (!caps.can_pop_frame || !caps.can_suspend) {
@@ -145,8 +134,7 @@
tot_result = STATUS_FAILED;
}
- if (vrb == 1)
- printf(">>>>>>>> Invoke PopFrame()\n");
+ printf(">>>>>>>> Invoke PopFrame()\n");
set_watch_ev(1); /* watch JVMTI events */
err = jvmti->PopFrame(frameThr);
@@ -155,17 +143,18 @@
err, TranslateError(err));
printf("\tFor more info about this error see the JVMTI spec.\n");
tot_result = STATUS_FAILED;
+ } else {
+ printf("Check #1 PASSED: PopFrame() is successfully done\n");
}
- else if (vrb == 1)
- printf("Check #1 PASSED: PopFrame() is successfully done\n");
set_watch_ev(0); /* ignore again JVMTI events */
if (gen_ev) {
printf("TEST FAILED: %d JVMTI events were generated by the function PopFrame()\n",
gen_ev);
tot_result = STATUS_FAILED;
- } else if (vrb == 1)
+ } else {
printf("Check #2 PASSED: No JVMTI events were generated by the function PopFrame()\n");
+ }
return(tot_result);
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe002.java Wed Dec 19 20:53:30 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe002.java Wed Dec 19 14:08:08 2018 -0800
@@ -46,7 +46,6 @@
static final int FAILED = 2;
static final int JCK_STATUS_BASE = 95;
- static boolean DEBUG_MODE = false;
static volatile boolean popFdone = false;
static volatile int totRes = PASSED;
private PrintStream out;
@@ -65,6 +64,10 @@
}
}
+ // t_case:
+ // 1 - PopFrame for NULL thread
+ // 2 - PopFrame for invalid thread (not Thread object)
+ // 3 - PopFrame for non-suspended thread
native static int doPopFrame(int t_case, popFrameCls popFrameClsThr);
public static void main(String[] argv) {
@@ -81,16 +84,12 @@
int retValue = 0;
this.out = out;
- for (int i = 0; i < argv.length; i++) {
- if (argv[i].equals("-v")) // verbose mode
- DEBUG_MODE = true;
- }
popFrameClsThr = new popFrameCls();
synchronized (barrier) { // force a child thread to pause
synchronized(readi) {
popFrameClsThr.start(); // start the child thread
-// wait until the thread will enter into a necessary method
+ // wait until the thread will enter into a necessary method
try {
readi.wait(); // wait for the child readiness
} catch (Exception e) {
@@ -100,53 +99,45 @@
}
}
-/* check that if PopFrame() would be invoked with NULL pointer to
- the thread, it will return the error JVMTI_ERROR_NULL_POINTER */
- if (DEBUG_MODE)
- totRes = retValue = doPopFrame(1, popFrameClsThr);
- else
- totRes = retValue = doPopFrame(0, popFrameClsThr);
- if (DEBUG_MODE && retValue == PASSED)
+ /* check that if PopFrame() would be invoked with NULL pointer to
+ the thread, it will return the error JVMTI_ERROR_NULL_POINTER */
+ totRes = retValue = doPopFrame(1, popFrameClsThr);
+ if (retValue == PASSED) {
out.println("Check #1 PASSED:\n" +
- "\tPopFrame(), being invoked with NULL pointer " +
- "to the thread,\n" +
- "\treturned the appropriate error JVMTI_ERROR_NULL_POINTER");
+ "\tPopFrame(), being invoked with NULL pointer " +
+ "to the thread,\n" +
+ "\treturned the appropriate error JVMTI_ERROR_NULL_POINTER");
+ }
-/* check that if the thread, whose top frame is to be popped,
- is invalid, the PopFrame() will return the error
- JVMTI_ERROR_INVALID_THREAD */
- if (DEBUG_MODE)
- retValue = doPopFrame(3, popFrameClsThr);
- else
- retValue = doPopFrame(2, popFrameClsThr);
+ /* check that if the thread, whose top frame is to be popped,
+ is invalid, the PopFrame() will return the error
+ JVMTI_ERROR_INVALID_THREAD */
+ retValue = doPopFrame(2, popFrameClsThr);
if (retValue == FAILED) {
popFdone = true;
totRes = FAILED;
- } else
- if (DEBUG_MODE && retValue == PASSED)
- out.println("Check #3 PASSED:\n" +
+ } else {
+ out.println("Check #2 PASSED:\n" +
"\tPopFrame(), being invoked with " +
"the invalid thread,\n" +
"\treturned the appropriate error " +
"JVMTI_ERROR_INVALID_THREAD");
+ }
-/* check that if the thread, whose top frame is to be popped,
- has not been suspended, the PopFrame() will return the error
- JVMTI_ERROR_THREAD_NOT_SUSPENDED */
- if (DEBUG_MODE)
- retValue = doPopFrame(5, popFrameClsThr);
- else
- retValue = doPopFrame(4, popFrameClsThr);
+ /* check that if the thread, whose top frame is to be popped,
+ has not been suspended, the PopFrame() will return the error
+ JVMTI_ERROR_THREAD_NOT_SUSPENDED */
+ retValue = doPopFrame(3, popFrameClsThr);
if (retValue == FAILED) {
popFdone = true;
totRes = FAILED;
- } else
- if (DEBUG_MODE && retValue == PASSED)
- out.println("Check #5 PASSED:\n" +
+ } else {
+ out.println("Check #3 PASSED:\n" +
"\tPopFrame(), being invoked with " +
"the non suspended thread,\n" +
"\treturned the appropriate error " +
"JVMTI_ERROR_THREAD_NOT_SUSPENDED");
+ }
}
return totRes;
@@ -159,17 +150,13 @@
if (popframe002.popFdone) { // popping has been done
out.println("TEST FAILED: frame with popFrameCls.run() was popped");
popframe002.totRes = FAILED;
- }
- else {
+ } else {
synchronized(readi) {
readi.notify(); // notify the main thread
}
}
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): inside run()");
try {
-// pause here and get the main thread a chance to run
+ // pause here and get the main thread a chance to run
synchronized (popframe002.barrier) {}
compl = false;
} catch (Exception e) {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe002/popframe002.cpp Wed Dec 19 20:53:30 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe002/popframe002.cpp Wed Dec 19 14:08:08 2018 -0800
@@ -102,13 +102,10 @@
}
switch (t_case) {
-/* NULL pointer to the thread in debug mode */
+ /* NULL pointer to the thread*/
case 1:
printf("\nInvoke PopFrame() with NULL pointer to a thread...\n");
fflush(stdout);
- // fallthrough
-/* NULL pointer to the thread */
- case 0:
set_watch_ev(1); /* watch JVMTI events */
err = (jvmti->PopFrame(NULL)); /* explode the bomb */
if (err != JVMTI_ERROR_INVALID_THREAD) {
@@ -118,13 +115,10 @@
tot_result = STATUS_FAILED;
}
break;
-/* invalid thread in debug mode */
- case 3:
+ /* invalid thread */
+ case 2:
printf("\nInvoke PopFrame() for an invalid thread...\n");
fflush(stdout);
- // fallthrough
-/* invalid thread */
- case 2:
set_watch_ev(1); /* watch JVMTI events */
err = (jvmti->PopFrame(cls)); /* explode the bomb */
set_watch_ev(0); /* ignore again JVMTI events */
@@ -135,13 +129,10 @@
tot_result = STATUS_FAILED;
}
break;
-/* non suspended thread in debug mode */
- case 5:
+ /* non suspended thread */
+ case 3:
printf("\nInvoke PopFrame() for a non suspended thread...\n");
fflush(stdout);
- // fallthrough
-/* non suspended thread */
- case 4:
set_watch_ev(1); /* watch JVMTI events */
err = (jvmti->PopFrame(frameThr)); /* explode the bomb */
set_watch_ev(0); /* ignore again JVMTI events */
@@ -152,6 +143,9 @@
tot_result = STATUS_FAILED;
}
break;
+ default:
+ printf("\nTEST ERROR: unexpected case: %lld\n", (long long)t_case);
+
}
if (gen_ev) {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003.java Wed Dec 19 20:53:30 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003.java Wed Dec 19 14:08:08 2018 -0800
@@ -41,7 +41,6 @@
public static final int FAILED = 2;
static final int JCK_STATUS_BASE = 95;
- public static boolean DEBUG_MODE = false;
private popframe003p popFrameClsThr;
static {
@@ -55,9 +54,9 @@
}
}
- native static int doPopFrame(int vrb, popframe003p popFrameClsThr);
- native static int suspThread(int vrb, popframe003p popFrameClsThr);
- native static int resThread(int vrb, popframe003p popFrameClsThr);
+ native static int doPopFrame(popframe003p popFrameClsThr);
+ native static int suspThread(popframe003p popFrameClsThr);
+ native static int resThread(popframe003p popFrameClsThr);
public static void main(String[] argv) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
@@ -72,12 +71,7 @@
private int runIt(String argv[], PrintStream out) {
int retValue = 0;
- for (int i = 0; i < argv.length; i++) {
- if (argv[i].equals("-v")) // verbose mode
- DEBUG_MODE = true;
- }
-
- popFrameClsThr = new popframe003p("Tested Thread", out, DEBUG_MODE);
+ popFrameClsThr = new popframe003p("Tested Thread", out);
// start the child thread
popFrameClsThr.start();
popFrameClsThr.startingBarrier.waitFor();
@@ -85,36 +79,27 @@
synchronized (popFrameClsThr.barrier) {
}
- if (DEBUG_MODE) {
- out.println("Going to suspend the thread...");
- retValue = suspThread(1, popFrameClsThr);
- } else
- retValue = suspThread(0, popFrameClsThr);
+ out.println("Going to suspend the thread...");
+ retValue = suspThread(popFrameClsThr);
if (retValue != PASSED) {
out.println("TEST: failed to suspend thread");
return FAILED;
}
// pop the frame
- if (DEBUG_MODE) {
- out.println("Going to pop a frame...");
- retValue = doPopFrame(1, popFrameClsThr);
- } else
- retValue = doPopFrame(0, popFrameClsThr);
+ out.println("Going to pop a frame...");
+ retValue = doPopFrame(popFrameClsThr);
popFrameClsThr.popFrameHasBeenDone();
if (retValue != PASSED) {
out.println("TEST: failed to pop frame");
- resThread(0, popFrameClsThr);
+ resThread(popFrameClsThr);
return FAILED;
}
- if (DEBUG_MODE) {
- out.println("Going to resume the thread...");
- retValue = resThread(1, popFrameClsThr);
- } else
- retValue = resThread(0, popFrameClsThr);
+ out.println("Going to resume the thread...");
+ retValue = resThread(popFrameClsThr);
if (retValue != PASSED) {
out.println("TEST: failed to resume thread");
return FAILED;
@@ -147,10 +132,10 @@
"\t\tbooleanPubStatGlFld=" + popframe003p.booleanPubStatGlFld + "\texpected: true\n" +
"\t\tstrPubStatGlFld=\"" + popframe003p.strPubStatGlFld + "\"\texpected: \"sttc glbl fld\"");
return FAILED;
+ } else {
+ out.println("Check #6 PASSED: changes for the static fields of a class,\n" +
+ "\twhich have been made in the popped frame's method, remained\n");
}
- else if (DEBUG_MODE)
- out.println("Check #6 PASSED: changes for the static fields of a class,\n" +
- "\twhich have been made in the popped frame's method, remained\n");
return popframe003p.totRes;
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003/popframe003.cpp Wed Dec 19 20:53:30 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003/popframe003.cpp Wed Dec 19 14:08:08 2018 -0800
@@ -77,53 +77,42 @@
}
JNIEXPORT jint JNICALL
-Java_nsk_jvmti_PopFrame_popframe003_suspThread(JNIEnv *env,
- jclass cls, jint vrb, jobject susThr) {
- jvmtiError err;
-
+Java_nsk_jvmti_PopFrame_popframe003_suspThread(JNIEnv *env, jclass cls, jobject susThr) {
if (!caps.can_pop_frame || !caps.can_suspend) {
return PASSED;
}
- if (vrb == 1)
- printf(">>>>>>>> Invoke SuspendThread()\n");
- err = jvmti->SuspendThread(susThr);
+ printf(">>>>>>>> Invoke SuspendThread()\n");
+ jvmtiError 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;
}
- if (vrb == 1)
- printf("<<<<<<<< SuspendThread() is successfully done\n");
+ printf("<<<<<<<< SuspendThread() is successfully done\n");
return PASSED;
}
JNIEXPORT jint JNICALL
-Java_nsk_jvmti_PopFrame_popframe003_resThread(JNIEnv *env, jclass cls, jint vrb,
- jobject susThr) {
- jvmtiError err;
-
+Java_nsk_jvmti_PopFrame_popframe003_resThread(JNIEnv *env, jclass cls, jobject susThr) {
if (!caps.can_pop_frame || !caps.can_suspend) {
return PASSED;
}
- if (vrb == 1)
- printf(">>>>>>>> Invoke ResumeThread()\n");
- err = jvmti->ResumeThread(susThr);
+ printf(">>>>>>>> Invoke ResumeThread()\n");
+ jvmtiError 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;
}
- if (vrb == 1)
- printf("<<<<<<<< ResumeThread() is successfully done\n");
+ printf("<<<<<<<< ResumeThread() is successfully done\n");
return PASSED;
}
JNIEXPORT jint JNICALL
-Java_nsk_jvmti_PopFrame_popframe003_doPopFrame(JNIEnv *env, jclass cls, jint vrb,
- jobject frameThr) {
+Java_nsk_jvmti_PopFrame_popframe003_doPopFrame(JNIEnv *env, jclass cls, jobject frameThr) {
jvmtiError err;
if (!caps.can_pop_frame || !caps.can_suspend) {
@@ -146,8 +135,7 @@
tot_result = STATUS_FAILED;
}
- if (vrb == 1)
- printf(">>>>>>>> Invoke PopFrame()\n");
+ printf(">>>>>>>> Invoke PopFrame()\n");
set_watch_ev(1); /* watch JVMTI events */
err = jvmti->PopFrame(frameThr);
@@ -157,16 +145,18 @@
printf("\tFor more info about this error see the JVMTI spec.\n");
tot_result = STATUS_FAILED;
}
- else if (vrb == 1)
+ else {
printf("Check #1 PASSED: PopFrame() is successfully done\n");
+ }
set_watch_ev(0); /* ignore again JVMTI events */
if (gen_ev) {
printf("TEST FAILED: %d JVMTI events were generated by the function PopFrame()\n",
gen_ev);
tot_result = STATUS_FAILED;
- } else if (vrb == 1)
+ } else {
printf("Check #2 PASSED: No JVMTI events were generated by the function PopFrame()\n");
+ }
return(tot_result);
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003p.java Wed Dec 19 20:53:30 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003p.java Wed Dec 19 14:08:08 2018 -0800
@@ -34,7 +34,6 @@
static final int FAILED = 2;
private PrintStream out;
- private boolean DEBUG_MODE;
public static volatile int totRes = PASSED;
public static Object barrier = new Object();
@@ -76,10 +75,9 @@
private popFrameCls popframeCls;
- popframe003p(String name, PrintStream out, boolean verbose) {
+ popframe003p(String name, PrintStream out) {
super(name);
this.out = out;
- DEBUG_MODE = verbose;
startingBarrier = new Wicket();
popframeCls = new popFrameCls();
}
@@ -124,10 +122,11 @@
"\t\tbooleanPubGlFld=" + booleanPubGlFld + "\texpected: true\n" +
"\t\tstrPubGlFld=\"" + strPubGlFld + "\"\texpected: null\n");
totRes = FAILED;
- } else if (DEBUG_MODE)
+ } else {
out.println("Check #5 PASSED: changes for the instance fields of a class,\n" +
- "\twhich have been made in the popped frame's method, remained\n" +
- "popframe003p (" + this + "): exiting...");
+ "\twhich have been made in the popped frame's method, remained\n" +
+ "popframe003p (" + this + "): exiting...");
+ }
}
class popFrameCls {
@@ -149,9 +148,7 @@
boolean compl = true;
if (popFrameHasBeenDone) { // popping has been done
- if (DEBUG_MODE)
- out.println("popframe003p (" + this +
- "): enter activeMeth() after popping");
+ out.println("popframe003p (" + this + "): enter activeMeth() after popping");
/* check that any changes for the arguments,
* which occurred in the called method, remain
*/
@@ -162,9 +159,10 @@
"\tcurrent argument values: i=" + i + " l=" + l +
" d=" + d + " c='" + c + "'\n");
totRes = FAILED;
- } else if (DEBUG_MODE)
+ } else {
out.println("Check #3 PASSED: changes for the arguments of " +
- "the popped frame's method, remained\n");
+ "the popped frame's method, remained\n");
+ }
/* check that any changes for the class fields,
* which occurred in the called method, remain
*/
@@ -185,10 +183,11 @@
"\t\tbooleanPubFld=" + booleanPubFld + "\texpected: false\n" +
"\t\tstrPubFld=\"" + strPubFld + "\"\texpected: \"static fld\"\n");
totRes = FAILED;
- } else if (DEBUG_MODE)
+ } else {
out.println("Check #4 PASSED: changes for the fields of an inner class,\n" +
- "\twhich have been made in the popped frame's method, remained\n" +
- "popframe003p (" + this + "): exiting...\n");
+ "\twhich have been made in the popped frame's method, remained\n" +
+ "popframe003p (" + this + "): exiting...\n");
+ }
return;
}
@@ -248,13 +247,9 @@
try {
// notify the main thread about readiness
synchronized (barrier) {
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): notifying main thread");
+ out.println("popFrameCls (" + this + "): notifying main thread");
startingBarrier.unlock();
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): inside activeMethod()");
+ out.println("popFrameCls (" + this + "): inside activeMethod()");
}
// loop until the main thread pops us
int ii = 0;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004.java Wed Dec 19 20:53:30 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004.java Wed Dec 19 14:08:08 2018 -0800
@@ -26,7 +26,7 @@
import java.io.*;
/**
- * This test checks that a method's frame can be popped by the JVMTI
+ * This test checks that a method's frame can not be popped by the JVMTI
* function <code>PopFrame()</code>:
* <li>with intermediate native frames, and a thread, from which
* the PopFrame() was called, is different than the current thread
@@ -41,7 +41,6 @@
public static final int FAILED = 2;
static final int JCK_STATUS_BASE = 95;
- static boolean DEBUG_MODE = false;
static volatile boolean popFdone = false;
static volatile boolean popF2done = false;
static volatile int totRes = PASSED;
@@ -60,8 +59,8 @@
}
}
- native void nativeMeth(int vrb, popFrameCls popFrameClsThr);
- native static int doPopFrame(int t_case, Thread popFrameClsThr);
+ native void nativeMeth(popFrameCls popFrameClsThr);
+ native static int doPopFrame(boolean otherThread, Thread popFrameClsThr);
native static int getResult();
public static void main(String[] argv) {
@@ -78,29 +77,22 @@
int retValue = 0;
this.out = out;
- for (int i = 0; i < argv.length; i++) {
- if (argv[i].equals("-v")) // verbose mode
- DEBUG_MODE = true;
- }
PipedInputStream pipeIn = new PipedInputStream();
popFrameClsThr = new popFrameCls(pipeIn);
synchronized (barrier) { // force a child thread to pause
popFrameClsThr.start(); // start a separate thread
-// wait until the thread will enter into a necessary method
+ // wait until the thread will enter into a necessary method
try {
int _byte = pipeIn.read();
} catch (IOException e) {
out.println("TEST FAILED: reading from a pipe: caught " + e);
return FAILED;
}
-// pop the frame
+ // pop the frame
if (popFrameClsThr.isAlive()) {
- if (DEBUG_MODE) {
- out.println("Going to pop the frame...");
- retValue=doPopFrame(1, popFrameClsThr);
- } else
- retValue=doPopFrame(0, popFrameClsThr);
+ out.println("Going to pop the frame on other thread...");
+ retValue = doPopFrame(true, popFrameClsThr);
popFdone = true;
if (retValue != PASSED)
return FAILED;
@@ -125,23 +117,17 @@
totRes = FAILED;
}
- if (DEBUG_MODE) {
- out.println("Going to pop the native frame...");
- totRes=doPopFrame(5, Thread.currentThread());
- } else
- totRes=doPopFrame(4, Thread.currentThread());
-
+ out.println("Going to pop the native frame on the current thread...");
+ totRes = doPopFrame(false, Thread.currentThread());
if (totRes != PASSED)
return FAILED;
else return getResult();
}
class popFrameCls extends Thread {
- private PipedInputStream pipeIn;
private PipedOutputStream pipeOut;
popFrameCls(PipedInputStream pipeIn) {
- this.pipeIn = pipeIn;
try {
pipeOut = new PipedOutputStream(pipeIn);
} catch (IOException e) {
@@ -152,63 +138,31 @@
}
public void run() {
- if (DEBUG_MODE)
- nativeMeth(1, popFrameClsThr);
- else nativeMeth(0, popFrameClsThr);
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): exiting...");
+ nativeMeth(popFrameClsThr);
+ out.println("popFrameCls (" + this + "): exiting...");
}
public void activeMethod() {
int retVal = FAILED;
boolean compl = true;
- if (popframe004.popFdone) { // popping has been done
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): enter activeMethod() after popping");
-// test case #2: popping from the current thread
- if (!popframe004.popF2done) {
- popframe004.popF2done = true;
- if (DEBUG_MODE) {
- out.println("popFrameCls (" + this +
- "): going to pop a frame from the current thread...");
- retVal = doPopFrame(3, popFrameClsThr);
- } else
- retVal = doPopFrame(2, popFrameClsThr);
- if (retVal != PASSED)
- popframe004.totRes = FAILED;
- }
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): leaving activeMethod()...");
- return;
- }
try {
pipeOut.write(123); // notify the main thread
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): inside activeMethod()");
-// pause here until the main thread suspends us
+ out.println("popFrameCls (" + this + "): inside activeMethod()");
+ // pause here until the main thread suspends us
synchronized (popframe004.barrier) {
while (true) {
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): looping...");
+ out.println("popFrameCls (" + this + "): looping...");
if (popframe004.popFdone) { // popping has been done
// popping has not to be done due to native frame
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): exiting activeMethod()...");
+ out.println("popFrameCls (" + this + "): exiting activeMethod()...");
compl = false;
return;
}
}
}
} catch (Exception e) {
- out.println("FAILURE: popFrameCls (" + this +
- "): caught " + e);
+ out.println("FAILURE: popFrameCls (" + this + "): caught " + e);
popframe004.totRes = FAILED;
compl = false;
} finally {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004/TestDescription.java Wed Dec 19 20:53:30 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004/TestDescription.java Wed Dec 19 14:08:08 2018 -0800
@@ -29,7 +29,7 @@
* VM Testbase keywords: [quick, jpda, jvmti, noras]
* VM Testbase readme:
* DESCRIPTION
- * This test checks that a method's frame can be popped by
+ * This test checks that a method's frame can not be popped by
* the JVMTI function PopFrame():
* - with intermediate native frames, and a thread, from which
* the PopFrame() was called, is different than the current thread;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004/popframe004.cpp Wed Dec 19 20:53:30 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004/popframe004.cpp Wed Dec 19 14:08:08 2018 -0800
@@ -77,68 +77,64 @@
jvmti->RawMonitorExit(watch_ev_monitor);
}
-int suspThread(jint vrb, jobject susThr) {
- jvmtiError err;
-
+int suspThread(jobject susThr) {
if (!caps.can_pop_frame || !caps.can_suspend) {
return PASSED;
}
- if (vrb == 1) {
- printf(">>>>>>>> Invoke SuspendThread()\n");
- fflush(stdout);
- }
- err = jvmti->SuspendThread(susThr);
+ printf(">>>>>>>> Invoke SuspendThread()\n");
+ fflush(stdout);
+
+ jvmtiError 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;
}
- if (vrb == 1) {
- printf("<<<<<<<< SuspendThread() is successfully done\n");
- fflush(stdout);
- }
+ printf("<<<<<<<< SuspendThread() is successfully done\n");
+ fflush(stdout);
+
return PASSED;
}
-int resThread(jint vrb, jobject susThr) {
+int resThread(jobject susThr) {
+ if (!caps.can_pop_frame || !caps.can_suspend) {
+ return PASSED;
+ }
+
+ printf(">>>>>>>> Invoke ResumeThread()\n");
+ fflush(stdout);
+
+ jvmtiError 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;
+ }
+
+ printf("<<<<<<<< ResumeThread() is successfully done\n");
+ fflush(stdout);
+
+ return PASSED;
+}
+
+JNIEXPORT jint JNICALL
+Java_nsk_jvmti_PopFrame_popframe004_doPopFrame(JNIEnv *env, jclass cls, jboolean otherThread,
+ jobject frameThr) {
jvmtiError err;
+ if (popDone) {
+ return PASSED;
+ }
+
if (!caps.can_pop_frame || !caps.can_suspend) {
return PASSED;
}
- if (vrb == 1) {
- printf(">>>>>>>> Invoke ResumeThread()\n");
- fflush(stdout);
- }
- 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;
- }
- if (vrb == 1) {
- printf("<<<<<<<< ResumeThread() is successfully done\n");
- fflush(stdout);
+ if (otherThread) { /* we are in a different thread */
+ if (suspThread(frameThr) != PASSED)
+ return STATUS_FAILED;
}
- return PASSED;
-}
-
-JNIEXPORT jint JNICALL
-Java_nsk_jvmti_PopFrame_popframe004_doPopFrame(JNIEnv *env, jclass cls, jint t_case,
- jobject frameThr) {
- jvmtiError err;
-
- if (popDone) return PASSED;
-
- if (!caps.can_pop_frame || !caps.can_suspend) {
- return PASSED;
- }
-
- if (t_case <= 1) /* we are in a different thread */
- if (suspThread(t_case, frameThr) != PASSED)
- return STATUS_FAILED;
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
JVMTI_EVENT_METHOD_EXIT, frameThr);
@@ -156,26 +152,29 @@
tot_result = STATUS_FAILED;
}
- if (t_case & 1) {
- printf(">>>>>>>> Invoke PopFrame()\n");
- fflush(stdout);
- }
+ printf(">>>>>>>> Invoke PopFrame()\n");
+ fflush(stdout);
set_watch_ev(1); /* watch JVMTI events */
err = jvmti->PopFrame(frameThr);
- if (err == JVMTI_ERROR_NONE) {
- printf("Check #%d FAILED: PopFrame() was unexpectedly done\n", t_case);
+ switch (err) {
+ case JVMTI_ERROR_NONE:
+ printf("Check FAILED: PopFrame() was unexpectedly done\n");
tot_result = STATUS_FAILED;
- } else if (err != JVMTI_ERROR_NO_MORE_FRAMES &&
- err != JVMTI_ERROR_OPAQUE_FRAME) {
- printf("Check #%d FAILED: PopFrame() returned unexpected error %d: %s\n",
- t_case, err, TranslateError(err));
+ break;
+ case JVMTI_ERROR_NO_MORE_FRAMES:
+ case JVMTI_ERROR_OPAQUE_FRAME:
+ case JVMTI_ERROR_THREAD_NOT_SUSPENDED:
+ printf("Check PASSED: PopFrame() failed as expected with %d: %s\n",
+ err, TranslateError(err));
+ fflush(stdout);
+ break;
+ default:
+ printf("Check FAILED: PopFrame() returned unexpected error %d: %s\n",
+ err, TranslateError(err));
printf("\tFor more info about this error please refer to the JVMTI spec.\n");
tot_result = STATUS_FAILED;
- } else if (t_case & 1) {
- printf("Check #%d PASSED: PopFrame() failed as expected with %d: %s\n",
- t_case, err, TranslateError(err));
- fflush(stdout);
+ break;
}
set_watch_ev(0); /* ignore again JVMTI events */
@@ -183,15 +182,16 @@
printf("TEST FAILED: %d JVMTI events were generated by the function PopFrame()\n",
gen_ev);
tot_result = STATUS_FAILED;
- } else if (t_case & 1) {
- printf("Check #%d PASSED: No JVMTI events were generated by the function PopFrame()\n",
- t_case+1);
+ } else {
+ printf("Check PASSED: No JVMTI events were generated by the function PopFrame()\n");
fflush(stdout);
}
- if (t_case <= 1) /* we are in a different thread */
- return resThread(t_case, frameThr);
- else popDone = 1; /* stop looping */
+ if (otherThread) { /* we are in a different thread */
+ return resThread(frameThr);
+ } else {
+ popDone = 1; /* stop looping */
+ }
return PASSED;
}
@@ -276,8 +276,7 @@
return (tot_result);
}
-void nativeMeth2(JNIEnv *env, jobject obj, jint vrb,
- jobject frameThr) {
+void nativeMeth2(JNIEnv *env, jobject obj, jobject frameThr) {
jclass cls = env->GetObjectClass(frameThr);
jmethodID mid = NULL;
@@ -287,21 +286,16 @@
tot_result = STATUS_FAILED;
return;
}
- if (vrb == 1) {
- printf("nativeMeth2(): calling the Java activeMethod()\n");
- fflush(stdout);
- }
+ printf("nativeMeth2(): calling the Java activeMethod()\n");
+ fflush(stdout);
env->CallVoidMethod(frameThr, mid);
}
JNIEXPORT void JNICALL
-Java_nsk_jvmti_PopFrame_popframe004_nativeMeth(JNIEnv *env, jobject obj, jint vrb,
- jobject frameThr) {
- if (vrb == 1) {
- printf("nativeMeth(): calling the native nativeMeth2()\n");
- fflush(stdout);
- }
- nativeMeth2(env, obj, vrb, frameThr);
+Java_nsk_jvmti_PopFrame_popframe004_nativeMeth(JNIEnv *env, jobject obj, jobject frameThr) {
+ printf("nativeMeth(): calling the native nativeMeth2()\n");
+ fflush(stdout);
+ nativeMeth2(env, obj, frameThr);
}
}
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe005.java Wed Dec 19 20:53:30 2018 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe005.java Wed Dec 19 14:08:08 2018 -0800
@@ -37,7 +37,6 @@
public class popframe005 {
static final int WAIT_TIME = 2000;
- static boolean DEBUG_MODE = false;
static volatile int testedStep = 0; /* 0- action no yet started
1- a frame is to be popped
2- checking monitors state
@@ -78,19 +77,15 @@
Object lockObj[] = new Object[2];
this.out = out;
- for (int i = 0; i < argv.length; i++) {
- if (argv[i].equals("-v")) // verbose mode
- DEBUG_MODE = true;
- }
lockObj[0] = new Object();
lockObj[1] = new Object();
- startGuarantee = new Wicket("startGuarantee", 1, (DEBUG_MODE ? System.out : null));
- finishGuarantee = new Wicket("finishGuarantee", 1, (DEBUG_MODE ? System.out : null));
+ startGuarantee = new Wicket("startGuarantee", 1, System.out);
+ finishGuarantee = new Wicket("finishGuarantee", 1, System.out);
allThreadsStoppedGuarantee =
- new Wicket("allThreadsStoppedGuarantee", 3, (DEBUG_MODE ? System.out : null));
+ new Wicket("allThreadsStoppedGuarantee", 3, System.out);
// start a thread whose top frame is to be popped
popFrameClsThr = new popFrameCls("Tested Thread", lockObj);
@@ -109,20 +104,16 @@
// pause until the first thread exit notification-block
allThreadsStoppedGuarantee.waitFor();
synchronized (allThreadsStoppedBarrier) {
- if (DEBUG_MODE) {
- out.println("Passed barrier in main thread");
- out.flush();
- }
+ out.println("Passed barrier in main thread");
+ out.flush();
}
/////////////////////// popping a frame ////////////////////////
testedStep = 1;
- if (DEBUG_MODE) {
- out.println("State transition: testedStep: 0->1");
- out.println("Going to pop the frame...");
- out.flush();
- }
+ out.println("State transition: testedStep: 0->1");
+ out.println("Going to pop the frame...");
+ out.flush();
boolean retValue = doPopFrame(popFrameClsThr);
@@ -133,10 +124,8 @@
///////////////////// check monitors state /////////////////////
testedStep = 2;
- if (DEBUG_MODE) {
- out.println("State transition: testedStep: 1->2");
- out.flush();
- }
+ out.println("State transition: testedStep: 1->2");
+ out.flush();
if (!popFrameClsThr.isAlive()) {
out.println("TEST FAILURE: thread with the method's popped frame is dead");
@@ -146,8 +135,7 @@
try {
objWaiterThr2.join(WAIT_TIME);
} catch (InterruptedException e) {
- if (DEBUG_MODE)
- out.println("Joining the objWaiterThr2's thread: caught " + e);
+ out.println("Joining the objWaiterThr2's thread: caught " + e);
}
if (objWaiterThr2.isAlive()) { // objWaiterThr2 should be dead
@@ -158,10 +146,8 @@
try {
objWaiterThr1.join(WAIT_TIME);
} catch (InterruptedException e) {
- if (DEBUG_MODE) {
- out.println("Joining the objWaiterThr1's thread: caught " + e);
- out.flush();
- }
+ out.println("Joining the objWaiterThr1's thread: caught " + e);
+ out.flush();
}
if (!objWaiterThr1.isAlive()) { // objWaiterThr2 should be alive
out.println("TEST FAILED: Lock acquired by a frame, different from the popped one,\n"
@@ -172,10 +158,8 @@
/////////////////////// finish the test ///////////////////////
testedStep = 3;
- if (DEBUG_MODE) {
- out.println("State transition: testedStep: 2->3");
- out.flush();
- }
+ out.println("State transition: testedStep: 2->3");
+ out.flush();
finishGuarantee.unlock();
@@ -209,29 +193,22 @@
synchronized(lockObj[0]) {
activeMethod();
}
- if (DEBUG_MODE)
- out.println("popFrameCls (" + this +
- "): exiting..."); out.flush();
+ out.println("popFrameCls (" + this + "): exiting...");
+ out.flush();
}
public void activeMethod() {
boolean compl = true;
if (popframe005.testedStep != 0) { // popping has been done
- if (DEBUG_MODE) {
- out.println("popFrameCls (" + this +
- "): enter activeMethod() after popping");
- out.flush();
- }
+ out.println("popFrameCls (" + this + "): enter activeMethod() after popping");
+ out.flush();
// wait for checking monitors state by the main thread
finishGuarantee.waitFor();
- if (DEBUG_MODE) {
- out.println("popFrameCls (" + this +
- "): leaving activeMethod()");
- out.flush();
- }
+ out.println("popFrameCls (" + this + "): leaving activeMethod()");
+ out.flush();
return;
}
@@ -239,10 +216,8 @@
try {
synchronized(lockObj[1]) {
synchronized(allThreadsStoppedBarrier) {
- if (DEBUG_MODE) {
- out.println("popFrameCls (" + this + "): inside activeMethod()");
- out.flush();
- }
+ out.println("popFrameCls (" + this + "): inside activeMethod()");
+ out.flush();
// notify the main thread
startGuarantee.unlock();
@@ -301,12 +276,10 @@
public void run() {
// notify the main thread
synchronized(allThreadsStoppedBarrier) {
- if (DEBUG_MODE) {
- out.println("objWaiter(" + this +
- "): waiting for a lockObj" + objIdent +
- "'s monitor; testedStep=" + testedStep);
- out.flush();
- }
+ out.println("objWaiter(" + this +
+ "): waiting for a lockObj" + objIdent +
+ "'s monitor; testedStep=" + testedStep);
+ out.flush();
allThreadsStoppedGuarantee.unlock();
}
@@ -317,17 +290,15 @@
out.println("TEST FAILED: the lockObj" + objIdent +
"'s monitor became free too early");
result = Consts.TEST_FAILED;
- } else if (DEBUG_MODE) {
+ } else {
out.println("Check PASSED: objWaiter(" + this +
"): enter the lockObj" + objIdent + "'s monitor");
out.flush();
}
}
- if (DEBUG_MODE) {
- out.println("objWaiter (" + this + "): exiting...");
- out.flush();
- }
+ out.println("objWaiter (" + this + "): exiting...");
+ out.flush();
} catch (Exception e) {
out.println("TEST FAILURE: objWaiter (" + this + "): caught " + e);
}