提交 b3d9ed11 编写于 作者: J jjh

6263966: TEST: com/sun/jdi/ClassesByName2Test.java has a race

Summary: Have the debuggee stop at a bkpt instead of running to completion.
Reviewed-by: tbell
上级 d001e0ef
......@@ -41,8 +41,7 @@ import java.util.*;
/********** target program **********/
class ClassesByName2Targ {
public static void ready() {
System.out.println("Ready!");
static void bkpt() {
}
public static void main(String[] args){
......@@ -74,22 +73,24 @@ class ClassesByName2Targ {
}
};
ready();
two.start();
one.start();
zero.start();
try {
zero.join();
System.out.println("zero joined");
one.join();
System.out.println("one joined");
two.join();
System.out.println("two joined");
} catch (InterruptedException iex) {
iex.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
bkpt();
System.out.println("Goodbye from ClassesByName2Targ!");
}
}
......@@ -97,29 +98,64 @@ class ClassesByName2Targ {
/********** test program **********/
public class ClassesByName2Test extends TestScaffold {
volatile boolean stop = false;
ClassesByName2Test (String args[]) {
super(args);
}
public void breakpointReached(BreakpointEvent event) {
System.out.println("Got BreakpointEvent: " + event);
stop = true;
}
public void eventSetComplete(EventSet set) {
// Don't resume.
}
public static void main(String[] args) throws Exception {
new ClassesByName2Test(args).startTests();
}
void breakpointAtMethod(ReferenceType ref, String methodName)
throws Exception {
List meths = ref.methodsByName(methodName);
if (meths.size() != 1) {
throw new Exception("test error: should be one " +
methodName);
}
Method meth = (Method)meths.get(0);
BreakpointRequest bkptReq = vm().eventRequestManager().
createBreakpointRequest(meth.location());
bkptReq.enable();
try {
addListener (this);
} catch (Exception ex){
ex.printStackTrace();
failure("failure: Could not add listener");
throw new Exception("ClassesByname2Test: failed");
}
}
protected void runTests() throws Exception {
/*
* Get to the top of ready()
*/
startTo("ClassesByName2Targ", "ready", "()V");
BreakpointEvent bpe = startToMain("ClassesByName2Targ");
/*
Bug 6263966 - Don't just resume because the debuggee can
complete and disconnect while the following loop is
accessing it.
*/
breakpointAtMethod(bpe.location().declaringType(), "bkpt");
vm().resume();
int i = 0;
while (i < 8 && !vmDisconnected) {
i++;
/* The test of 'stop' is so that we stop when the debuggee hits
the bkpt. The 150 is so we stop if the debuggee
is slow (eg, -Xcomp -server) - we don't want to
spend all day waiting for it to get to the bkpt.
*/
for (int i = 0; i < 150 && !stop; i++) {
List all = vm().allClasses();
System.out.println("");
System.out.println("++++ Lookup number: " + i + ". allClasses() returned " +
System.out.println("\n++++ Lookup number: " + i + ". allClasses() returned " +
all.size() + " classes.");
for (Iterator it = all.iterator(); it.hasNext(); ) {
ReferenceType cls = (ReferenceType)it.next();
......@@ -135,9 +171,8 @@ public class ClassesByName2Test extends TestScaffold {
}
}
// Doing vm().exit(0) instead of listenUntilVMDisconnect()
// speeds up the test up by more than 50% in -server -Xcomp (solsparc32-fastdebug)
// In case of a slow debuggee, we don't want to resume the debuggee and wait
// for it to complete.
vm().exit(0);
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册