24 package nsk.jvmti.PopFrame; 25 26 import nsk.share.Wicket; 27 import java.io.PrintStream; 28 29 /** 30 * This test checks that after popping a method's frame by the JVMTI 31 * function <code>PopFrame()</code>: 32 * <li>the method arguments will be added back and any changes to 33 * the arguments, which occurred in the called method, will remain 34 * <li>changes to global state, which occurred in the called method, 35 * will remain 36 * <li>no JVMTI events are generated by the function <code>PopFrame()</code> 37 * <br><br>The test was changed due to the bug 4448675. 38 */ 39 public class popframe003 { 40 public static final int PASSED = 0; 41 public static final int FAILED = 2; 42 static final int JCK_STATUS_BASE = 95; 43 44 public static boolean DEBUG_MODE = false; 45 private popframe003p popFrameClsThr; 46 47 static { 48 try { 49 System.loadLibrary("popframe003"); 50 } catch (UnsatisfiedLinkError e) { 51 System.err.println("Could not load popframe003 library"); 52 System.err.println("java.library.path:" + 53 System.getProperty("java.library.path")); 54 throw e; 55 } 56 } 57 58 native static int doPopFrame(int vrb, popframe003p popFrameClsThr); 59 native static int suspThread(int vrb, popframe003p popFrameClsThr); 60 native static int resThread(int vrb, popframe003p popFrameClsThr); 61 62 public static void main(String[] argv) { 63 argv = nsk.share.jvmti.JVMTITest.commonInit(argv); 64 65 System.exit(run(argv, System.out) + JCK_STATUS_BASE); 66 } 67 68 public static int run(String argv[], PrintStream out) { 69 return new popframe003().runIt(argv, out); 70 } 71 72 private int runIt(String argv[], PrintStream out) { 73 int retValue = 0; 74 75 for (int i = 0; i < argv.length; i++) { 76 if (argv[i].equals("-v")) // verbose mode 77 DEBUG_MODE = true; 78 } 79 80 popFrameClsThr = new popframe003p("Tested Thread", out, DEBUG_MODE); 81 // start the child thread 82 popFrameClsThr.start(); 83 popFrameClsThr.startingBarrier.waitFor(); 84 // pause until the child thread exits notification-block 85 synchronized (popFrameClsThr.barrier) { 86 } 87 88 if (DEBUG_MODE) { 89 out.println("Going to suspend the thread..."); 90 retValue = suspThread(1, popFrameClsThr); 91 } else 92 retValue = suspThread(0, popFrameClsThr); 93 if (retValue != PASSED) { 94 out.println("TEST: failed to suspend thread"); 95 return FAILED; 96 } 97 98 // pop the frame 99 if (DEBUG_MODE) { 100 out.println("Going to pop a frame..."); 101 retValue = doPopFrame(1, popFrameClsThr); 102 } else 103 retValue = doPopFrame(0, popFrameClsThr); 104 105 popFrameClsThr.popFrameHasBeenDone(); 106 107 if (retValue != PASSED) { 108 out.println("TEST: failed to pop frame"); 109 resThread(0, popFrameClsThr); 110 return FAILED; 111 } 112 113 if (DEBUG_MODE) { 114 out.println("Going to resume the thread..."); 115 retValue = resThread(1, popFrameClsThr); 116 } else 117 retValue = resThread(0, popFrameClsThr); 118 if (retValue != PASSED) { 119 out.println("TEST: failed to resume thread"); 120 return FAILED; 121 } 122 123 try { 124 popFrameClsThr.join(); 125 } catch (InterruptedException e) { 126 out.println("TEST INCOMPLETE: caught " + e); 127 return FAILED; 128 } 129 130 /* check that any changes for the static global fields, 131 * which occurred in the called method, remain 132 */ 133 if (popframe003p.bytePubStatGlFld != 2 || popframe003p.shortPubStatGlFld != 3 || 134 popframe003p.intPubStatGlFld != 4 || popframe003p.longPubStatGlFld != 5L || 135 popframe003p.floatPubStatGlFld != 6.2F || popframe003p.doublePubStatGlFld != 7.35D || 136 popframe003p.charPubStatGlFld != 'b' || popframe003p.booleanPubStatGlFld != true || 137 !popframe003p.strPubStatGlFld.equals("sttc glbl fld")) { 138 out.println("TEST FAILED: changes for the static fields of a class,\n" + 139 "\twhich have been made in the popped frame's method, did not remain:\n" + 140 "\tstatic fields values:\n\t\tbytePubStatGlFld=" + popframe003p.bytePubStatGlFld + "\texpected: 2\n" + 141 "\t\tshortPubStatGlFld=" + popframe003p.shortPubStatGlFld + "\texpected: 3\n" + 142 "\t\tintPubStatGlFld=" + popframe003p.intPubStatGlFld + "\texpected: 4\n" + 143 "\t\tlongPubStatGlFld=" + popframe003p.longPubStatGlFld + "\texpected: 5\n" + 144 "\t\tfloatPubStatGlFld=" + popframe003p.floatPubStatGlFld + "\texpected: 6.2\n" + 145 "\t\tdoublePubStatGlFld=" + popframe003p.doublePubStatGlFld + "\texpected: 7.35\n" + 146 "\t\tcharPubStatGlFld='" + popframe003p.charPubStatGlFld + "'\texpected: 'b'\n" + 147 "\t\tbooleanPubStatGlFld=" + popframe003p.booleanPubStatGlFld + "\texpected: true\n" + 148 "\t\tstrPubStatGlFld=\"" + popframe003p.strPubStatGlFld + "\"\texpected: \"sttc glbl fld\""); 149 return FAILED; 150 } 151 else if (DEBUG_MODE) 152 out.println("Check #6 PASSED: changes for the static fields of a class,\n" + 153 "\twhich have been made in the popped frame's method, remained\n"); 154 155 return popframe003p.totRes; 156 } 157 } | 24 package nsk.jvmti.PopFrame; 25 26 import nsk.share.Wicket; 27 import java.io.PrintStream; 28 29 /** 30 * This test checks that after popping a method's frame by the JVMTI 31 * function <code>PopFrame()</code>: 32 * <li>the method arguments will be added back and any changes to 33 * the arguments, which occurred in the called method, will remain 34 * <li>changes to global state, which occurred in the called method, 35 * will remain 36 * <li>no JVMTI events are generated by the function <code>PopFrame()</code> 37 * <br><br>The test was changed due to the bug 4448675. 38 */ 39 public class popframe003 { 40 public static final int PASSED = 0; 41 public static final int FAILED = 2; 42 static final int JCK_STATUS_BASE = 95; 43 44 private popframe003p popFrameClsThr; 45 46 static { 47 try { 48 System.loadLibrary("popframe003"); 49 } catch (UnsatisfiedLinkError e) { 50 System.err.println("Could not load popframe003 library"); 51 System.err.println("java.library.path:" + 52 System.getProperty("java.library.path")); 53 throw e; 54 } 55 } 56 57 native static int doPopFrame(popframe003p popFrameClsThr); 58 native static int suspThread(popframe003p popFrameClsThr); 59 native static int resThread(popframe003p popFrameClsThr); 60 61 public static void main(String[] argv) { 62 argv = nsk.share.jvmti.JVMTITest.commonInit(argv); 63 64 System.exit(run(argv, System.out) + JCK_STATUS_BASE); 65 } 66 67 public static int run(String argv[], PrintStream out) { 68 return new popframe003().runIt(argv, out); 69 } 70 71 private int runIt(String argv[], PrintStream out) { 72 int retValue = 0; 73 74 popFrameClsThr = new popframe003p("Tested Thread", out); 75 // start the child thread 76 popFrameClsThr.start(); 77 popFrameClsThr.startingBarrier.waitFor(); 78 // pause until the child thread exits notification-block 79 synchronized (popFrameClsThr.barrier) { 80 } 81 82 out.println("Going to suspend the thread..."); 83 retValue = suspThread(popFrameClsThr); 84 if (retValue != PASSED) { 85 out.println("TEST: failed to suspend thread"); 86 return FAILED; 87 } 88 89 // pop the frame 90 out.println("Going to pop a frame..."); 91 retValue = doPopFrame(popFrameClsThr); 92 93 popFrameClsThr.popFrameHasBeenDone(); 94 95 if (retValue != PASSED) { 96 out.println("TEST: failed to pop frame"); 97 resThread(popFrameClsThr); 98 return FAILED; 99 } 100 101 out.println("Going to resume the thread..."); 102 retValue = resThread(popFrameClsThr); 103 if (retValue != PASSED) { 104 out.println("TEST: failed to resume thread"); 105 return FAILED; 106 } 107 108 try { 109 popFrameClsThr.join(); 110 } catch (InterruptedException e) { 111 out.println("TEST INCOMPLETE: caught " + e); 112 return FAILED; 113 } 114 115 /* check that any changes for the static global fields, 116 * which occurred in the called method, remain 117 */ 118 if (popframe003p.bytePubStatGlFld != 2 || popframe003p.shortPubStatGlFld != 3 || 119 popframe003p.intPubStatGlFld != 4 || popframe003p.longPubStatGlFld != 5L || 120 popframe003p.floatPubStatGlFld != 6.2F || popframe003p.doublePubStatGlFld != 7.35D || 121 popframe003p.charPubStatGlFld != 'b' || popframe003p.booleanPubStatGlFld != true || 122 !popframe003p.strPubStatGlFld.equals("sttc glbl fld")) { 123 out.println("TEST FAILED: changes for the static fields of a class,\n" + 124 "\twhich have been made in the popped frame's method, did not remain:\n" + 125 "\tstatic fields values:\n\t\tbytePubStatGlFld=" + popframe003p.bytePubStatGlFld + "\texpected: 2\n" + 126 "\t\tshortPubStatGlFld=" + popframe003p.shortPubStatGlFld + "\texpected: 3\n" + 127 "\t\tintPubStatGlFld=" + popframe003p.intPubStatGlFld + "\texpected: 4\n" + 128 "\t\tlongPubStatGlFld=" + popframe003p.longPubStatGlFld + "\texpected: 5\n" + 129 "\t\tfloatPubStatGlFld=" + popframe003p.floatPubStatGlFld + "\texpected: 6.2\n" + 130 "\t\tdoublePubStatGlFld=" + popframe003p.doublePubStatGlFld + "\texpected: 7.35\n" + 131 "\t\tcharPubStatGlFld='" + popframe003p.charPubStatGlFld + "'\texpected: 'b'\n" + 132 "\t\tbooleanPubStatGlFld=" + popframe003p.booleanPubStatGlFld + "\texpected: true\n" + 133 "\t\tstrPubStatGlFld=\"" + popframe003p.strPubStatGlFld + "\"\texpected: \"sttc glbl fld\""); 134 return FAILED; 135 } else { 136 out.println("Check #6 PASSED: changes for the static fields of a class,\n" + 137 "\twhich have been made in the popped frame's method, remained\n"); 138 } 139 140 return popframe003p.totRes; 141 } 142 } |