/*
* 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 6751643
* @summary ThreadReference.ownedMonitors() can return null
*
* @author jjh
*
* @run build TestScaffold VMConnection TargetListener TargetAdapter
* @run compile -g SimulResumerTest.java
*/
/*
* This debuggee basically runs two threads each of
* which loop, hitting a bkpt in each iteration.
*
*/
static boolean one = false;
}
super(name);
}
public void run() {
run1();
} else {
run2();
}
}
public void bkpt1(int i) {
synchronized(name1) {
yield();
}
}
public void run1() {
int i = 0;
while (i < count) {
i++;
bkpt1(i);
}
}
public void bkpt2(int i) {
synchronized(name2) {
yield();
}
}
public void run2() {
int i = 0;
while (i < count) {
i++;
bkpt2(i);
}
}
}
/********** test program **********/
super(args);
}
}
/* BreakpointEvent handler */
// save ThreadRefs for the two debuggee threads
if (bkpts == 0) {
}
}
synchronized("abc") {
bkpts++;
}
/**
if (bkpts >= SimulResumerTarg.count * 2) {
resumerThread.interrupt();
}
*****/
}
/********** test core **********/
// This calls each ThreadReference method that could fail due to the bug
// that occurs if a resume is done while a call to the method is in process.
try {
kind = "ownedMonitors()";
failure("failure: ownedMonitors = null");
}
kind = "ownedMonitorsAndFrames()";
failure("failure: ownedMonitorsAndFrames = null");
}
kind = "currentContendedMonitor()";
// no failure return value here; could cause an NPE
kind = "frames()";
// no failure return value here; could cause an NPE
if (nframes > 0) {
// hmm, how could it ever be 0?
kind = "frames(0, size - 1)";
}
kind = "frameCount()";
failure("failure: frameCount = -1");
}
kind = "name()";
failure("failure: name = null");
}
kind = "status()";
failure("failure: status < 0");
}
} catch (IncompatibleThreadStateException ee) {
// ignore
} catch (VMDisconnectedException ee) {
// This is how we stop. The debuggee runs to completion
// and we get this exception.
throw ee;
}
}
}
/*
* Get to the top of main()
* to determine targetClass and mainThread
*/
/*
* Set event requests
*/
/*
* This thread will be started when we get the first bkpt.
*/
public void run() {
while (true) {
iters++;
try {
} catch (InterruptedException ee) {
// If the test completes, this occurs.
println("resumer Interrupted");
break;
} catch (VMDisconnectedException ee) {
println("VMDisconnectedException");
break;
}
}
}
};
/*
* resume the target, listening for events
*/
/*
* deal with results of test
* if anything has called failure("foo") testFailed will be true
*/
if (!testFailed) {
} else {
}
}
}