1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
|
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package nsk.jvmti.PopFrame;
import nsk.share.Wicket;
import java.io.PrintStream;
/**
* This is auxiliary tested class
*/
public class popframe003p extends Thread {
static final int PASSED = 0;
static final int FAILED = 2;
private PrintStream out;
public static volatile int totRes = PASSED;
public static Object barrier = new Object();
public Wicket startingBarrier;
// dummy global static fields
static public byte bytePubStatGlFld = 1;
static public short shortPubStatGlFld = 2;
static public int intPubStatGlFld = 3;
static public long longPubStatGlFld = 4L;
static public float floatPubStatGlFld = 5.1F;
static public double doublePubStatGlFld = 6.2D;
static public char charPubStatGlFld = 'a';
static public boolean booleanPubStatGlFld = false;
static public String strPubStatGlFld = "static global field";
// dummy instance fields
byte byteGlFld = 11;
short shortGlFld = 22;
int intGlFld = 33;
long longGlFld = 44L;
private float floatGlFld = 55F;
double doubleGlFld = 66D;
char charGlFld = 'c';
boolean booleanGlFld = true;
String strGlFld = "instance field";
Object objGl = this;
// dummy public instance fields
public byte bytePubGlFld = 0;
public short shortPubGlFld = -2;
public int intPubGlFld = -3;
public long longPubGlFld = -4L;
public float floatPubGlFld = -5.1F;
public double doublePubGlFld = -6.2D;
public char charPubGlFld = 'e';
public boolean booleanPubGlFld = false;
public String strPubGlFld = "public instance field";
private popFrameCls popframeCls;
popframe003p(String name, PrintStream out) {
super(name);
this.out = out;
startingBarrier = new Wicket();
popframeCls = new popFrameCls();
}
public void run() {
popframeCls.activeMeth(1, Long.MAX_VALUE,
Double.MIN_VALUE, 'c', false);
/* check that any changes for the global instance fields,
* which occurred in the called method, remain
*/
if (byteGlFld != 1 || shortGlFld != 2 ||
intGlFld != 3 || longGlFld != 4L ||
floatGlFld != 5.1F || doubleGlFld != 6.2D ||
charGlFld != 'd' || booleanGlFld != false ||
!strGlFld.equals("nstnc fld") || !objGl.equals(Integer.valueOf("1973")) ||
bytePubGlFld != 7 || shortPubGlFld != 8 ||
intPubGlFld != 9 || longPubGlFld != -10L ||
floatPubGlFld != -11F || doublePubGlFld != -12D ||
charPubGlFld != 'z' || booleanPubGlFld != false ||
strPubGlFld != null) {
out.println("TEST FAILED: changes for the instance fields of a class,\n" +
"\twhich have been made in the popped frame's method, did not remain:\n" +
"\tinstance fields values:\n\t\tbyteGlFld=" +
byteGlFld + "\texpected: 1\n" +
"\t\tshortGlFld=" + shortGlFld + "\texpected: 2\n" +
"\t\tintGlFld=" + intGlFld + "\texpected: 3\n" +
"\t\tlongGlFld=" + longGlFld + "\texpected: 4\n" +
"\t\tfloatGlFld=" + floatGlFld + "\texpected: 5.1\n" +
"\t\tdoubleGlFld=" + doubleGlFld + "\texpected: 6.2\n" +
"\t\tcharGlFld='" + charGlFld + "'\texpected: 'd'\n" +
"\t\tbooleanGlFld=" + booleanGlFld + "\texpected: false\n" +
"\t\tstrGlFld=\"" + strGlFld + "\"\texpected: \"nstnc fld\"\n" +
"\t\tobjGl=\"" + objGl.toString() + "\"\texpected: \"123\"\n" +
"\tpublic instance fields values:\n\t\tbytePubGlFld=" +
bytePubGlFld + "\texpected: 2\n" +
"\t\tshortPubGlFld=" + shortPubGlFld + "\texpected: 3\n" +
"\t\tintPubGlFld=" + intPubGlFld + "\texpected: 4\n" +
"\t\tlongPubGlFld=" + longPubGlFld + "\texpected: 5\n" +
"\t\tfloatPubGlFld=" + floatPubGlFld + "\texpected: 6.2\n" +
"\t\tdoublePubGlFld=" + doublePubGlFld + "\texpected: 7.35\n" +
"\t\tcharPubGlFld='" + charPubGlFld + "'\texpected: 'b'\n" +
"\t\tbooleanPubGlFld=" + booleanPubGlFld + "\texpected: true\n" +
"\t\tstrPubGlFld=\"" + strPubGlFld + "\"\texpected: null\n");
totRes = FAILED;
} 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...");
}
}
class popFrameCls {
// dummy popFrameCls fields
protected byte bytePubFld = 10;
public short shortPubFld = 20;
public int intPubFld = 30;
public long longPubFld = 40L;
public float floatPubFld = 50.1F;
public double doublePubFld = 60.2D;
public char charPubFld = 'b';
public boolean booleanPubFld = true;
protected String strPubFld = "static field";
// flag to notify when exit from 'while' loop in activeMeth method
public volatile boolean popFrameHasBeenDone = false;
void activeMeth(int i, long l, double d, char c, boolean b) {
boolean compl = true;
if (popFrameHasBeenDone) { // popping has been done
out.println("popframe003p (" + this + "): enter activeMeth() after popping");
/* check that any changes for the arguments,
* which occurred in the called method, remain
*/
if (i != 2 || l != Long.MIN_VALUE ||
d != Double.MAX_VALUE || c != 'c' || b != true) {
out.println("TEST FAILED: changes for the arguments of " +
"the popped frame's method, did not remain\n" +
"\tcurrent argument values: i=" + i + " l=" + l +
" d=" + d + " c='" + c + "'\n");
totRes = FAILED;
} else {
out.println("Check #3 PASSED: changes for the arguments of " +
"the popped frame's method, remained\n");
}
/* check that any changes for the class fields,
* which occurred in the called method, remain
*/
if (bytePubFld != 0 || shortPubFld != 0 ||
intPubFld != 0 || longPubFld != 0L ||
floatPubFld != 0F || doublePubFld != 0D ||
charPubFld != ' ' || booleanPubFld != false ||
!strPubFld.equals("static fld")) {
out.println("TEST FAILED: changes for the fields of an inner class,\n" +
"\twhich have been made in the popped frame's method, did not remain:\n" +
"\tstatic fields values:\n\t\tbytePubFld=" + bytePubFld + "\texpected: 0\n" +
"\t\tshortPubFld=" + shortPubFld + "\texpected: 0\n" +
"\t\tintPubFld=" + intPubFld + "\texpected: 0\n" +
"\t\tlongPubFld=" + longPubFld + "\texpected: 0\n" +
"\t\tfloatPubFld=" + floatPubFld + "\texpected: 0\n" +
"\t\tdoublePubFld=" + doublePubFld + "\texpected: 0\n" +
"\t\tcharPubFld='" + charPubFld + "'\texpected: ' '\n" +
"\t\tbooleanPubFld=" + booleanPubFld + "\texpected: false\n" +
"\t\tstrPubFld=\"" + strPubFld + "\"\texpected: \"static fld\"\n");
totRes = FAILED;
} 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");
}
return;
}
// make some variable changes:
// for the arguments
i = 2;
l = Long.MIN_VALUE;
d = Double.MAX_VALUE;
b = true;
// for the global static fields
bytePubStatGlFld = 2;
shortPubStatGlFld = 3;
intPubStatGlFld = 4;
longPubStatGlFld = 5L;
floatPubStatGlFld = 6.2F;
doublePubStatGlFld = 7.35D;
charPubStatGlFld = 'b';
booleanPubStatGlFld = true;
strPubStatGlFld = "sttc glbl fld";
// for the global instance fields
byteGlFld = 1;
shortGlFld = 2;
intGlFld = 3;
longGlFld = 4L;
floatGlFld = 5.1F;
doubleGlFld = 6.2D;
charGlFld = 'd';
booleanGlFld = false;
strGlFld = "nstnc fld";
objGl = Integer.valueOf(1973);
// for the global public instance fields
bytePubGlFld = 7;
shortPubGlFld = 8;
intPubGlFld = 9;
longPubGlFld = -10L;
floatPubGlFld = -11F;
doublePubGlFld = -12D;
charPubGlFld = 'z';
booleanPubGlFld = false;
strPubGlFld = null;
// for the popFrameCls public fields
bytePubFld = 0;
shortPubFld = 0;
intPubFld = 0;
longPubFld = 0L;
floatPubFld = 0F;
doublePubFld = 0D;
charPubFld = ' ';
booleanPubFld = false;
strPubFld = "static fld";
try {
// notify the main thread about readiness
synchronized (barrier) {
out.println("popFrameCls (" + this + "): notifying main thread");
startingBarrier.unlock();
out.println("popFrameCls (" + this + "): inside activeMethod()");
}
// loop until the main thread pops us
int ii = 0;
int n = 1000;
while (!popFrameHasBeenDone) {
if (n <= 0) {
n = 1000;
}
if (ii > n) {
ii = 0;
n--;
}
ii++;
}
// popping has been done
out.println("TEST FAILED: a tested frame has not been really popped");
totRes = FAILED;
compl = false;
} catch (Exception e) {
out.println("FAILURE: popframe003p (" + this + "): caught " + e);
totRes = FAILED;
compl = false;
} finally {
if (compl) {
out.println("TEST FAILED: finally block was executed after PopFrame()");
totRes = FAILED;
}
}
}
}
public void popFrameHasBeenDone() {
popframeCls.popFrameHasBeenDone = true;
}
}
|