aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjjh <none@none>2008-09-22 19:20:08 -0700
committerjjh <none@none>2008-09-22 19:20:08 -0700
commite5b3bef48bddb41bef3c269e14339b8b8a2d8ac6 (patch)
tree9cec6d77bd1fe7b7d9e53d8fa1d0712016b26403
parent5e84f9a276dc294d82ad03d21cbfb1eb77d86be6 (diff)
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
-rw-r--r--test/com/sun/jdi/ClassesByName2Test.java67
1 files changed, 51 insertions, 16 deletions
diff --git a/test/com/sun/jdi/ClassesByName2Test.java b/test/com/sun/jdi/ClassesByName2Test.java
index 3bdab5d47..76fe9250d 100644
--- a/test/com/sun/jdi/ClassesByName2Test.java
+++ b/test/com/sun/jdi/ClassesByName2Test.java
@@ -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);
/*