< prev index next >
test/vmTestbase/nsk/jvmti/PopFrame/popframe002.java
Print this page
@@ -44,11 +44,10 @@
public class popframe002 {
static final int PASSED = 0;
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;
private popFrameCls popFrameClsThr;
static Object readi = new Object(); // for notification about readiness
@@ -63,10 +62,14 @@
System.getProperty("java.library.path"));
throw e;
}
}
+ // 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) {
argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
@@ -79,77 +82,65 @@
private int runIt(String argv[], PrintStream out) {
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) {
out.println("TEST FAILURE: waiting for " +
popFrameClsThr.toString() + ": caught " + e);
return FAILED;
}
}
-/* check that if PopFrame() would be invoked with NULL pointer to
+ /* 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)
+ 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");
+ }
-/* check that if the thread, whose top frame is to be popped,
+ /* 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);
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,
+ /* 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);
+ 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;
}
class popFrameCls extends Thread {
@@ -157,21 +148,17 @@
boolean compl = true;
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) {
out.println("FAILURE: popFrameCls (" + this +
"): caught " + e);
< prev index next >