use of com.sun.jdi.event.StepEvent in project jdk8u_jdk by JetBrains.
the class LambdaStepTest method runTests.
/********** test core **********/
protected void runTests() throws Exception {
// ## Normal instance method
BreakpointEvent bpe = startTo("LambdaStepTestTarg", "instanceTest", "()V");
ThreadReference thread = bpe.thread();
// step over allocation
StepEvent se = stepOverLine(thread);
System.out.println(se.thread().frame(0));
// step into test();
se = stepIntoLine(thread);
System.out.println(se.thread().frame(0));
// step over variable initialization
se = stepOverLine(thread);
System.out.println(se.thread().frame(0));
// get value of variable "from"
StackFrame frame = se.thread().frame(0);
LocalVariable lv = frame.visibleVariableByName("from");
System.out.println(lv);
StringReference sr = (StringReference) frame.getValue(lv);
if (!sr.value().equals("test")) {
throw new Exception("Unexpected variable value in instanceTest: " + sr.value());
}
// ## Lambda method
bpe = resumeTo("LambdaStepTestTarg", "lambdaTest", "()V");
thread = bpe.thread();
// step over allocation
se = stepOverLine(thread);
System.out.println(se.thread().frame(0));
// step into run() of the lambda
se = stepIntoLine(thread);
System.out.println(se.thread().frame(0));
// step over variable initialization
se = stepOverLine(thread);
System.out.println(se.thread().frame(0));
// get value of variable "from"
frame = se.thread().frame(0);
lv = frame.visibleVariableByName("from");
System.out.println(lv);
sr = (StringReference) frame.getValue(lv);
if (!sr.value().equals("lambda")) {
throw new Exception("Unexpected variable value in lambdaTest: " + sr.value());
}
// ## Default method
bpe = resumeTo("LambdaStepTestTarg", "defaultTest", "()V");
thread = bpe.thread();
// step over allocation
se = stepOverLine(thread);
System.out.println(se.thread().frame(0));
// step into defaultMethod()
se = stepIntoLine(thread);
System.out.println(se.thread().frame(0));
// step over variable initialization
se = stepOverLine(thread);
System.out.println(se.thread().frame(0));
// get value of variable "from"
frame = se.thread().frame(0);
lv = frame.visibleVariableByName("from");
System.out.println(lv);
sr = (StringReference) frame.getValue(lv);
if (!sr.value().equals("default")) {
throw new Exception("Unexpected variable value in lambdaTest: " + sr.value());
}
/*
* resume the target listening for events
*/
listenUntilVMDisconnect();
}
Aggregations