Search in sources :

Example 1 with StepEvent

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();
}
Also used : BreakpointEvent(com.sun.jdi.event.BreakpointEvent) StepEvent(com.sun.jdi.event.StepEvent) StackFrame(com.sun.jdi.StackFrame) LocalVariable(com.sun.jdi.LocalVariable) ThreadReference(com.sun.jdi.ThreadReference) StringReference(com.sun.jdi.StringReference)

Aggregations

LocalVariable (com.sun.jdi.LocalVariable)1 StackFrame (com.sun.jdi.StackFrame)1 StringReference (com.sun.jdi.StringReference)1 ThreadReference (com.sun.jdi.ThreadReference)1 BreakpointEvent (com.sun.jdi.event.BreakpointEvent)1 StepEvent (com.sun.jdi.event.StepEvent)1