// The debuggee just runs in a loop. The debugger // sets a bkpt on the Math.random call. When the // bkpt is hit, the debugger disables it, resumes // the debuggee, waits a bit, and enables the bkpt again.
class BreakpointTarg { publicfinalstaticint BKPT_LINE = 56;
publicstaticlong count; staticvoid doit() {
Object[] roots = new Object[200000]; while (true) { int index = (int) (Math.random() * roots.length); // BKPT_LINE // This println makes the test pass //System.out.println("Debuggee: index = " + index);
roots[index] = new Object(); // bkpt here passes // and null instead of new Object() // passes
count++;
}
}
publicstaticvoid main(String[] args) throws Exception { new BreakpointTest(args).startTests();
}
/********** event handlers **********/
staticint maxBkpts = 50; int bkptCount;
BreakpointRequest bkptRequest;
Field debuggeeCountField;
// When we get a bkpt we want to disable the request, // resume the debuggee, and then re-enable the request publicvoid breakpointReached(BreakpointEvent event) {
System.out.println("Got BreakpointEvent: " + bkptCount + ", debuggeeCount = " +
((LongValue)targetClass.
getValue(debuggeeCountField)).value()
);
bkptRequest.disable();
}
// The main thread watchs the bkptCount to // see if bkpts stop coming in. The // test _should_ fail well before maxBkpts bkpts. if (bkptCount++ < maxBkpts) { try { Thread.sleep(100);
} catch (InterruptedException ee) {
}
bkptRequest.enable();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.