publicvoid runTestOn(TestObject testObj, Method method) throws Exception {
System.out.println("Single call with PopFrame on " + testObj);
final Method methodExitCallback =
TestObject.class.getDeclaredMethod("methodExitCallback", Object.class); final CountDownLatch continue_latch = new CountDownLatch(1); final CountDownLatch startup_latch = new CountDownLatch(1);
Runnable await = () -> { try {
startup_latch.countDown();
continue_latch.await();
} catch (Exception e) { thrownew Error("Failed to await latch", e);
}
}; Thread thr = newThread(() -> {
await.run();
testObj.run();
art.SuspendEvents.clearTestData(Thread.currentThread());
});
thr.start();
// Wait until the other thread is started.
startup_latch.await();
// Setup suspension method on the thread.
art.SuspendEvents.setupSuspendExceptionEvent(method, /*is_catch=*/ false, thr);
art.SuspendEvents.enableMethodExitEvents(TestObject.class, methodExitCallback, thr);
// Let the other thread go.
continue_latch.countDown();
// Wait for the other thread to hit the breakpoint/watchpoint/whatever and suspend itself // (without re-entering java)
art.SuspendEvents.waitForSuspendHit(thr);
art.SuspendEvents.disableExceptionEvents(thr);
try { // Pop the frame.
popFrame(thr);
} catch (Exception e) {
System.out.println("Failed to pop frame due to " + e);
SafePrintStackTrace(e.getStackTrace());
}
// Start the other thread going again.
art.Suspension.resume(thr);
// Wait for the other thread to finish.
thr.join();
// See how many times calledFunction was called.
System.out.println("result is " + testObj);
}
publicvoid callerFunction() {
callerCnt++; try { if (isJit) { // This function should be re-executed by the popFrame.
calledFunctionJit();
} else { // This function should be re-executed by the popFrame.
calledFunction();
}
} catch(TestError e) {
System.out.println(e.getClass().getName() + " thrown and caught!");
}
}
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.