/**
* @test
* @bug 6459476
* @summary Debuggee is blocked, looks like running
*
* @author jjh
*
* @run build TestScaffold VMConnection TargetListener TargetAdapter
* @run compile -g InterruptHangTest.java
* @run main InterruptHangTest
*/
/*
* Debuggee has two threads. Debugger keeps stepping in
* the first thread. The second thread keeps interrupting the first
* thread. If a long time goes by with the debugger not getting
* a step event, the test fails.
*/
class InterruptHangTarg {
int answer = 0;
synchronized(sync) {
try {
} catch (InterruptedException ee) {
}
}
// Debugger will keep stepping thru this loop
answer++;
try {
// Give other thread a chance to run
} catch (InterruptedException ee) {
+ ii);
}
}
// Kill the interrupter thread
}
}
this.interruptee = interruptee;
}
public void run() {
synchronized(InterruptHangTarg.sync) {
}
int ii = 0;
while(true) {
ii++;
try {
} catch (InterruptedException ee) {
ii + " iterrupts");
break;
}
}
}
}
/********** test program **********/
super(args);
}
}
/********** event handlers **********/
synchronized(sync) {
nSteps++;
}
if (nSteps == 1) {
timerThread.start();
}
}
/********** test core **********/
/*
* Set event requests
*/
// Will be started by the step event handler
public void run() {
int mySteps = 0;
while (true) {
try {
synchronized(sync) {
// no step for 10 secs
failure("failure: Debuggee appears to be hung");
break;
}
}
} catch (InterruptedException ee) {
break;
}
}
}
};
/*
* resume the target listening for events
*/
/*
* deal with results of test
* if anything has called failure("foo") testFailed will be true
*/
if (!testFailed) {
println("InterruptHangTest: passed");
} else {
throw new Exception("InterruptHangTest: failed");
}
}
}