// test1 and test2 are testing for the bug described in 8292217. For this test MethodEntry // events are enabled when we hit the breakpoint, and we single step OVER (test1) or // INTO (test2) an instruction with an unresolved contant pool entry. The Debugger will // verify that the generated MethodEntry events during class loading are not improperly // co-located as described the the CR. publicstaticvoid test1() {
t1.foo(); // BREAKPOINT_1
} publicstaticvoid test2() {
t2.foo(); // BREAKPOINT_2
}
// Tests that MethodEntry, Step, and Breakpoint events that occur at the same // location are properly co-located in the same EventSet. MethodEntry and Step // are enabled when we hit BREAKPOINT_3 above. When the BreakpointEvent for // BREAKPOINT_4 is generated, the EventSet should also include a StepEvent // and a MethodEntryEvent. publicstaticvoid test3() { int x = 1; // BREAKPOINT_4
}
// Same as test3 but only check for co-located MethodEntry and Breakpoint events. // MethodEntry is enabled when we hit BREAKPOINT_5 above. StepEvent is not enabled. // When the BreakpointEvent for BREAKPOINT_6 is generated, the EventSet should also // include a MethodEntryEvent. publicstaticvoid test4() { int x = 1; // BREAKPOINT_6
}
// Same as test3 but only check for co-located Step and Breakpoint events. // StepEvents are enabled when we hit BREAKPOINT_7 above. When the BreakpointEvent // for BREAKPOINT_8 is generated, the EventSet should also include a StepEvent, publicstaticvoid test5() { int x = 1; // BREAKPOINT_8
}
// Same as test3 but only check for co-located MethodEntry and Step events. // MethodEntry and Step events are enabled when we hit BREAKPOINT_9 above. When // the StepEvent is received, the EventSet should also include the MethodEntryEvent. publicstaticvoid test6() { int x = 1;
}
}
staticclass MethodBreakpointData { final String method; final String signature; finalint lineNumber; public MethodBreakpointData(String method, String signature, int lineNumber) { this.method = method; this.signature = signature; this.lineNumber = lineNumber;
}
}
// Table of all breakpoints based on method name and sig, plus the line number within the method. static MethodBreakpointData[] breakpoints = new MethodBreakpointData[] { new MethodBreakpointData("runTests", "()V", 3), // BREAKPOINT_3 new MethodBreakpointData("runTests", "()V", 4), // BREAKPOINT_5 new MethodBreakpointData("runTests", "()V", 5), // BREAKPOINT_7 new MethodBreakpointData("runTests", "()V", 6), // BREAKPOINT_9 new MethodBreakpointData("test1", "()V", 1), // BREAKPOINT_1 new MethodBreakpointData("test2", "()V", 1), // BREAKPOINT_2 new MethodBreakpointData("test3", "()V", 1), // BREAKPOINT_4 new MethodBreakpointData("test4", "()V", 1), // BREAKPOINT_6 new MethodBreakpointData("test5", "()V", 1) // BREAKPOINT_8
};
publicvoid eventSetReceived(EventSet set) {
System.out.println("\nEventSet for test case #" + testcase + ": " + set); switch (testcase) { case1: case2: { // During the first two test cases we should never receive an EventSet with // more than one Event in it. if (set.size() != 1) {
testcaseFailed = true; // For now, we expect the 2nd test cases to fail due to 8292217, // so don't fail the overall test run as a result of this failure. // There is a workaround in place that allows the 1st test case to pass. if (testcase == 1) {
testFailed = true;
}
System.out.println("TESTCASE #" + testcase + " FAILED" +
(testcase == 2 ? "(ignoring)" : "") + ": too many events in EventSet: " + set.size());
} break;
} case3: { // At some point during test3 we should receive co-located MethodEntry, Step, and Breakpoint events. if (isColocated(set, true, true, true)) {
testcaseFailed = false;
} break;
} case4: { // At some point during test4 we should receive co-located MethodEntry and Breakpoint events. if (isColocated(set, true, false, true)) {
testcaseFailed = false;
} break;
} case5: { // At some point during test5 we should receive co-located Step and Breakpoint events. if (isColocated(set, false, true, true)) {
testcaseFailed = false;
} break;
} case6: { // At some point during test6 we should receive co-located MethodEntry and Step events. if (isColocated(set, true, true, false)) {
testcaseFailed = false;
} break;
}
}
}
// Setup test1. Completion is checked for in stepCompleted(). if (breakpointCount == 1) {
testcaseFailed = false; // assume passing unless error detected
entryRequest.enable();
exitRequest.enable();
stepRequest = erm.createStepRequest(mainThread,
StepRequest.STEP_LINE,
StepRequest.STEP_OVER);
stepRequest.addCountFilter(1);
stepRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
stepRequest.enable();
}
// Setup test2. Completion is checked for in stepCompleted(). if (breakpointCount == 2) {
testcaseFailed = false; // assume passing unless error detected
entryRequest.enable();
exitRequest.enable();
stepRequest = erm.createStepRequest(mainThread,
StepRequest.STEP_LINE,
StepRequest.STEP_INTO);
stepRequest.addCountFilter(1);
stepRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
stepRequest.enable();
}
// Setup test3: MethodEntry, Step, and Breakpoint co-located events. // Completion is handled by the next breakpoint being hit. if (breakpointCount == 3) {
testcaseFailed = true; // assume failing unless pass detected
entryRequest.enable();
stepRequest = erm.createStepRequest(mainThread,
StepRequest.STEP_LINE,
StepRequest.STEP_INTO);
stepRequest.addCountFilter(1);
stepRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
stepRequest.enable();
} // Complete test3. We fail if we never saw the expected co-located events. if (breakpointCount == 4) { if (testcaseFailed) {
testFailed = true;
System.out.println("TESTCASE #3 FAILED: did not get MethodEntry, Step, and Breakpoint co-located events");
} else {
System.out.println("TESTCASE #3 PASSED");
}
}
// Setup test4: MethodEntry and Breakpoint co-located events. // Completion is handled by the next breakpoint being hit. if (breakpointCount == 5) {
testcaseFailed = true; // assume failing unless pass detected
entryRequest.enable();
} // Complete test4. We fail if we never saw the expected co-located events. if (breakpointCount == 6) {
entryRequest.disable(); if (testcaseFailed) {
testFailed = true;
System.out.println("TESTCASE #4 FAILED: did not get MethodEntry and Breakpoint co-located events");
} else {
System.out.println("TESTCASE #4 PASSED");
}
}
// Setup test5: Step and Breakpoint co-located events. // Completion is handled by the next breakpoint being hit. if (breakpointCount == 7) {
testcaseFailed = true; // assume failing unless pass detected
stepRequest = erm.createStepRequest(mainThread,
StepRequest.STEP_LINE,
StepRequest.STEP_INTO);
stepRequest.addCountFilter(1);
stepRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
stepRequest.enable();
} // Complete test5. We fail if we never saw the expected co-located events. if (breakpointCount == 8) { if (testcaseFailed) {
testFailed = true;
System.out.println("TESTCASE #5 FAILED: did not get Step and Breakpoint co-located events");
} else {
System.out.println("TESTCASE #5 PASSED");
}
}
// Setup test: MethodEntry and Step co-located events // Completion is handled by the stepCompleted() since there is no additional breakpoint. if (breakpointCount == 9) {
testcaseFailed = true; // assume failing unless pass detected
entryRequest.enable();
stepRequest = erm.createStepRequest(mainThread,
StepRequest.STEP_LINE,
StepRequest.STEP_INTO);
stepRequest.addCountFilter(1);
stepRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
stepRequest.enable();
}
}
publicvoid stepCompleted(StepEvent event) {
System.out.println("Got StepEvent: " + getLocationString(event.location()));
event.request().disable();
entryRequest.disable(); if (testcase == 6 && testcaseFailed) {
testFailed = true;
System.out.println("TESTCASE #6 FAILED: did not get MethodEntry and Step co-located events");
} if (testcase == 1 || testcase == 2 || testcase == 6) {
exitRequest.disable(); if (!testcaseFailed) { // We already did a println if the test failed.
System.out.println("TESTCASE #" + testcase + " PASSED");
}
}
}
publicvoid methodEntered(MethodEntryEvent event) {
System.out.println("Got MethodEntryEvent: " + getLocationString(event.location())); if (methodEntryCount++ == 25) {
entryRequest.disable(); // Just in case the test loses control.
}
}
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.