提交 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.*; ...@@ -41,8 +41,7 @@ import java.util.*;
/********** target program **********/ /********** target program **********/
class ClassesByName2Targ { class ClassesByName2Targ {
public static void ready() { static void bkpt() {
System.out.println("Ready!");
} }
public static void main(String[] args){ public static void main(String[] args){
...@@ -74,22 +73,24 @@ class ClassesByName2Targ { ...@@ -74,22 +73,24 @@ class ClassesByName2Targ {
} }
}; };
ready();
two.start(); two.start();
one.start(); one.start();
zero.start(); zero.start();
try { try {
zero.join(); zero.join();
System.out.println("zero joined");
one.join(); one.join();
System.out.println("one joined");
two.join(); two.join();
System.out.println("two joined");
} catch (InterruptedException iex) { } catch (InterruptedException iex) {
iex.printStackTrace(); iex.printStackTrace();
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
bkpt();
System.out.println("Goodbye from ClassesByName2Targ!"); System.out.println("Goodbye from ClassesByName2Targ!");
} }
} }
...@@ -97,29 +98,64 @@ class ClassesByName2Targ { ...@@ -97,29 +98,64 @@ class ClassesByName2Targ {
/********** test program **********/ /********** test program **********/
public class ClassesByName2Test extends TestScaffold { public class ClassesByName2Test extends TestScaffold {
volatile boolean stop = false;
ClassesByName2Test (String args[]) { ClassesByName2Test (String args[]) {
super(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 { public static void main(String[] args) throws Exception {
new ClassesByName2Test(args).startTests(); 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 { protected void runTests() throws Exception {
/* BreakpointEvent bpe = startToMain("ClassesByName2Targ");
* Get to the top of ready()
*/
startTo("ClassesByName2Targ", "ready", "()V");
/*
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(); vm().resume();
int i = 0; /* The test of 'stop' is so that we stop when the debuggee hits
while (i < 8 && !vmDisconnected) { the bkpt. The 150 is so we stop if the debuggee
i++; 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(); List all = vm().allClasses();
System.out.println(""); System.out.println("\n++++ Lookup number: " + i + ". allClasses() returned " +
System.out.println("++++ Lookup number: " + i + ". allClasses() returned " +
all.size() + " classes."); all.size() + " classes.");
for (Iterator it = all.iterator(); it.hasNext(); ) { for (Iterator it = all.iterator(); it.hasNext(); ) {
ReferenceType cls = (ReferenceType)it.next(); ReferenceType cls = (ReferenceType)it.next();
...@@ -135,9 +171,8 @@ public class ClassesByName2Test extends TestScaffold { ...@@ -135,9 +171,8 @@ public class ClassesByName2Test extends TestScaffold {
} }
} }
// In case of a slow debuggee, we don't want to resume the debuggee and wait
// Doing vm().exit(0) instead of listenUntilVMDisconnect() // for it to complete.
// speeds up the test up by more than 50% in -server -Xcomp (solsparc32-fastdebug)
vm().exit(0); vm().exit(0);
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册