/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*/
/**
* @test
* @bug 4467564
* @summary Test the popping of frames in synchronous context
* (that is, when stopped at an event)
*
* @author Robert Field
*
* @run build TestScaffold VMConnection TargetListener TargetAdapter
* @run compile -g PopSynchronousTest.java
* @run main PopSynchronousTest
*/
/********** target program **********/
class PopSynchronousTarg {
static String s;
synchronized void a(int y, boolean w) {
if (y == 6 && w) {
s += "@";
} else {
s += " aArgFail ";
}
}
if (h.equals("yo")) {
s += "[";
} else {
s += " bArgFail ";
}
a(6, true);
s += "]";
return s;
}
long c() {
s += "<";
synchronized (s) {
b("yo");
}
s += ">";
return 17;
}
static void p() {
s += "(";
if (sole.c() != 17) {
s += " cReturnFail ";
}
s += ")";
}
static void report() {
}
s = new String();
sole = new PopSynchronousTarg();
for (int i = 0; i < 100; ++i) {
p();
// System.out.println(s);
report();
}
}
}
/********** test program **********/
{"main-i", "p-e", "p-i", "c-e", "c-i", "b-e", "b-i", "a-e", "a-l", "b-l", "c-l", "p-l", "main-r", "report-e"};
{"", "", "(", "", "<", "", "[", "", "@", "]", ">", ")", "", ""};
super(args);
}
}
/********** test assist **********/
return frame;
}
}
return null;
}
}
" got: " + actual());
}
}
for (int i = 0; i < popMax; ++i) {
return i;
}
}
return -1;
}
}
if (!isTop(methodName)) {
" at top of stack, instead: " + name);
}
}
}
void incrementState() {
}
stateIndex = i;
return;
}
}
}
expected = "";
}
do {
}
checkState();
}
--stateIndex;
checkState();
}
checkState();
}
/********** test core **********/
/*
* Get to the top of main()
* to determine targetClass and mainThread
*/
/*
* Testing
*/
/* individual tests */
for (int i = 0; i < popMax; ++i) {
for (int j = i; j < popMax; ++j) {
resumeTo("report");
}
}
/* sequential tests */
println("TEST pop a b c p");
resumeTo("a");
pop("a");
pop("b");
pop("c");
pop("p");
resumeTo("report");
println("TEST pop a c p");
resumeTo("a");
pop("a");
pop("c");
pop("p");
resumeTo("report");
println("TEST stress a");
resumeTo("a");
for (int i = 0; i < 100; ++i) {
reenter("a");
}
resumeTo("report");
println("TEST stress c");
resumeTo("c");
for (int i = 0; i < 100; ++i) {
reenter("c");
}
resumeTo("report");
/*
* we are done, get rid of target
*/
/*
* deal with results of test
* if anything has called failure("foo") testFailed will be true
*/
if (!testFailed) {
println("PopSynchronousTest: passed");
} else {
throw new Exception("PopSynchronousTest: failed");
}
}
}