Java Code Examples for org.apache.harmony.jpda.tests.framework.jdwp.Value

Following code examples demonstrate how to use org.apache.harmony.jpda.tests.framework.jdwp.Valuefrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.apache.harmony.jpda.tests.framework.jdwp.Valueand various code implementation of this class.

  public void test() throws Throwable {
    Value xInitial = Value.createInt(42);
    Value xNormal = Value.createInt(7);
    Value xExceptional = xInitial;
    runDebugTest(
        config,
        NAME,
        breakpoint(NAME, "foo", 12),
        run(),
        checkLine(FILE, 12),
        checkLocal("x", xInitial),
        stepOver(),
        checkLine(FILE, 13),
        checkLocal("x", xInitial),
        stepOver(),
        checkLine(FILE, 14),
        checkLocal("x", xNormal),
        stepOver(),
        checkLine(FILE, 16),
        checkNoLocal("x"),
        run(),
        checkLine(FILE, 12),
        checkLocal("x", xInitial),
        stepOver(),
        checkLine(FILE, 14),
        checkLocal("x", xExceptional),
        stepOver(),
        checkLine(FILE, 16),
        checkNoLocal("x"),
        run());
  } 


  private void runContinuousTest(String debuggeeClassName) throws Throwable {
    runDebugTest(debuggeeClassName,
        breakpoint(debuggeeClassName, "main"),
        run(),
        stepUntil(StepKind.OVER, StepLevel.INSTRUCTION, debuggeeState -> {
          Map<String, Value> localValues = debuggeeState.getLocalValues();
          Assert.assertNotNull(localValues);

          return false;
        }));
  } 

    public void testThisObject() {
        logWriter.println("testThisObject started");

        EventContext context = stopInProxyMethod();

        Value proxyObjectValue = getExpectedProxyObjectValue();

        logWriter.println("==> Send StackFrame::ThisObject command...");
        CommandPacket packet = new CommandPacket(
                JDWPCommands.StackFrameCommandSet.CommandSetID,
                JDWPCommands.StackFrameCommandSet.ThisObjectCommand);
        packet.setNextValueAsThreadID(context.getThreadId());
        packet.setNextValueAsLong(context.getFrameId());
        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
        checkReplyPacket(reply, "StackFrame.ThisObject");
        TaggedObject taggedObject = reply.getNextValueAsTaggedObject();
        assertAllDataRead(reply);

        assertEquals("Unexpected object id", proxyObjectValue.getLongValue(),
                taggedObject.objectID);
        assertEquals("Unexpected object tag", proxyObjectValue.getTag(),
                taggedObject.tag);

        resumeDebuggee();

        logWriter.println("testThisObject finished");
    } 

  public void test() throws Throwable {
    Value int42 = Value.createInt(42);
    Value int7 = Value.createInt(7);
    runDebugTest(
        config,
        NAME,
        breakpoint(NAME, "bar"),
        run(),
        checkLine(FILE, 10),
        checkLocal("x", int42),
        inspect(
            t -> {
              FrameInspector frame = t.getFrame(1);
              frame.checkLine(FILE, 13);
              frame.checkLocal("x", int42);
              frame.setLocal("x", int7);
            }),
        run(),
        checkLine(FILE, 10),
        checkLocal("x", int7),
        run());
  } 

  private void runDebugger(DebugTestConfig config) throws Throwable {
    runDebugTest(
        config,
        CLASS,
        breakpoint(methodFromMethod(CLASS.getMethod("foo", Converter.class))),
        run(),
        checkLine(19),
        checkLocals("this", "converter"),
        checkFieldOnThis("outer", null, Value.createInt(42)),
        stepInto(INTELLIJ_FILTER),
        checkLine(25),
        checkLocals("this", "value", "arg"),
        checkNoLocal("outer"),
        checkFieldOnThis("outer", null, Value.createInt(42)),
        run());
  } 

  public void testLocalsOnBreakpoint() throws Throwable {
    runDebugTest(
        config,
        DEBUGGEE_CLASS,
        breakpoint(DEBUGGEE_CLASS, "bitwiseInts"),
        run(),
        checkLine(SOURCE_FILE, 12),
        checkLocal("x", Value.createInt(12345)),
        checkLocal("y", Value.createInt(54321)),
        run());
  } 

  public void testLocalsOnBreakpointThenStep() throws Throwable {
    runDebugTest(
        config,
        DEBUGGEE_CLASS,
        breakpoint(DEBUGGEE_CLASS, "bitwiseInts"),
        run(),
        checkLine(SOURCE_FILE, 12),
        checkLocal("x", Value.createInt(12345)),
        checkLocal("y", Value.createInt(54321)),
        stepOver(),
        checkLocal("x", Value.createInt(12345)),
        checkLocal("y", Value.createInt(54321)),
        run());
  } 

    protected void checkInvokeReply(ReplyPacket reply) {
        Value invokeResult = reply.getNextValueAsValue();
        assertNull("Expect null result value for 'void'", invokeResult);

        TaggedObject invokeException = reply.getNextValueAsTaggedObject();
        assertEquals("Invalid exception object id", 0, invokeException.objectID);
        assertAllDataRead(reply);

    } 

    protected void checkInvokeReply(ReplyPacket reply) {
        Value invokeResult = reply.getNextValueAsValue();
        assertNull("Expect null result value for 'void'", invokeResult);

        TaggedObject invokeException = reply.getNextValueAsTaggedObject();
        assertEquals("Invalid exception object id", 0, invokeException.objectID);
        assertAllDataRead(reply);
    } 

Advertisement
Javadoc
This class represents generic value used in JDWP packets.
Advertisement