当前位置: 首页>>代码示例>>Java>>正文


Java CommandPacket.setNextValueAsValue方法代码示例

本文整理汇总了Java中org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket.setNextValueAsValue方法的典型用法代码示例。如果您正苦于以下问题:Java CommandPacket.setNextValueAsValue方法的具体用法?Java CommandPacket.setNextValueAsValue怎么用?Java CommandPacket.setNextValueAsValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket的用法示例。


在下文中一共展示了CommandPacket.setNextValueAsValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: perform

import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; //导入方法依赖的package包/类
@Override
public void perform(JUnit3Wrapper testBase) {
  Optional<Variable> localVar =
      getVariableAt(testBase.getMirror(), testBase.debuggeeState.getLocation(), localName);
  Assert.assertTrue("No local '" + localName + "'", localVar.isPresent());

  CommandPacket setValues = new CommandPacket(StackFrameCommandSet.CommandSetID,
      StackFrameCommandSet.SetValuesCommand);
  setValues.setNextValueAsThreadID(testBase.getDebuggeeState().getThreadId());
  setValues.setNextValueAsFrameID(testBase.getDebuggeeState().getFrameId());
  setValues.setNextValueAsInt(1);
  setValues.setNextValueAsInt(localVar.get().getSlot());
  setValues.setNextValueAsValue(newValue);
  ReplyPacket replyPacket = testBase.getMirror().performCommand(setValues);
  testBase.checkReplyPacket(replyPacket, "StackFrame.SetValues");
}
 
开发者ID:inferjay,项目名称:r8,代码行数:17,代码来源:DebugTestBase.java

示例2: setLocalVars

import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; //导入方法依赖的package包/类
/**
 * Sets the value of one or more local variables
 * 
 * @param frame
 *            The frame ID.
 * @param vars
 *            An array of Variable objects whose values to set
 * @param values
 *            An array of Value objects to set
 */
public final void setLocalVars(Frame frame, Variable[] vars, Value[] values) {
    if (vars.length != values.length) {
        throw new TestErrorException(
                "Number of variables doesn't correspond to number of their values");
    }

    CommandPacket command = new CommandPacket(
            JDWPCommands.StackFrameCommandSet.CommandSetID,
            JDWPCommands.StackFrameCommandSet.SetValuesCommand);
    command.setNextValueAsThreadID(frame.getThreadID());
    command.setNextValueAsFrameID(frame.getID());
    command.setNextValueAsInt(vars.length);
    for (int i = 0; i < vars.length; i++) {
        command.setNextValueAsInt(vars[i].getSlot());
        command.setNextValueAsValue(values[i]);
    }

    checkReply(performCommand(command));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:30,代码来源:VmMirror.java

示例3: invokeInstanceMethod

import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; //导入方法依赖的package包/类
/**
 * Invokes a member method of the given object.
 * 
 * @param objectID
 *            The object ID.
 * @param threadID
 *            The thread ID.
 * @param methodName
 *            The name of method for the invocation.
 * @param args
 *            The arguments for the invocation.
 * @param options
 *            The invocation options.
 * @return ReplyPacket for corresponding command
 */
public final ReplyPacket invokeInstanceMethod(long objectID, long threadID,
        String methodName, Value[] args, int options) {
    long classID = getReferenceType(objectID);
    long methodID = getMethodID(classID, methodName);
    CommandPacket command = new CommandPacket(
            JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
            JDWPCommands.ObjectReferenceCommandSet.InvokeMethodCommand);
    command.setNextValueAsObjectID(objectID);
    command.setNextValueAsThreadID(threadID);
    command.setNextValueAsClassID(classID);
    command.setNextValueAsMethodID(methodID);
    command.setNextValueAsInt(args.length);
    for (int i = 0; i < args.length; i++) {
        command.setNextValueAsValue(args[i]);
    }
    command.setNextValueAsInt(options);

    return checkReply(performCommand(command));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:35,代码来源:VmMirror.java

示例4: invokeStaticMethod

import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; //导入方法依赖的package包/类
/**
 * Invokes a static method of the given class.
 * 
 * @param classID
 *            The class type ID.
 * @param threadID
 *            The thread ID.
 * @param methodName
 *            The name of method for the invocation.
 * @param args
 *            The arguments for the invocation.
 * @param options
 *            The invocation options.
 * @return ReplyPacket for corresponding command
 */
public final ReplyPacket invokeStaticMethod(long classID, long threadID,
        String methodName, Value[] args, int options) {
    long methodID = getMethodID(classID, methodName);
    CommandPacket command = new CommandPacket(
            JDWPCommands.ClassTypeCommandSet.CommandSetID,
            JDWPCommands.ClassTypeCommandSet.InvokeMethodCommand);
    command.setNextValueAsClassID(classID);
    command.setNextValueAsThreadID(threadID);
    command.setNextValueAsMethodID(methodID);
    command.setNextValueAsInt(args.length);
    for (int i = 0; i < args.length; i++) {
        command.setNextValueAsValue(args[i]);
    }
    command.setNextValueAsInt(options);

    return checkReply(performCommand(command));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:33,代码来源:VmMirror.java

示例5: testForceEarlyReturn_ReturnVoid

import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; //导入方法依赖的package包/类
/**
 * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
 * At first the test starts ForceEarlyReturnDebuggee and send it the thread
 * name through which to start a specific thread. Then the test performs the
 * ThreadReference.ForceEarlyReturn command for the tested thread and gets
 * the returned value of the called method. The returned value should be
 * equal to the value which is used in ForceEarlyReturn Command. In this
 * testcase, an Void value is returned.
 */
public void testForceEarlyReturn_ReturnVoid() {
    String thisTestName = "testForceEarlyReturn_ReturnVoid";
    logWriter.println("==> " + thisTestName + " for " + thisCommandName
            + ": START...");
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    if (!isCapability()) {
        logWriter
                .println("##WARNING: this VM dosn't possess capability:canForceEarlyReturn");
        return;
    }

    // Tell debuggee to start a thread named THREAD_VOID
    synchronizer.sendMessage(ForceEarlyReturnDebuggee.THREAD_VOID);

    // Wait until the func_Void is processing.
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    // Getting ID of the tested thread
    logWriter.println("==> testedThreadName = "
            + ForceEarlyReturnDebuggee.THREAD_VOID);
    logWriter.println("==> Get testedThreadID...");
    long testedThreadID = debuggeeWrapper.vmMirror
            .getThreadID(ForceEarlyReturnDebuggee.THREAD_VOID);
    logWriter.println("==> Get testedThreadID is" + testedThreadID);

    // Suspend the VM before perform command
    logWriter.println("==> testedThreadID = " + testedThreadID);
    logWriter.println("==> suspend testedThread...");
    debuggeeWrapper.vmMirror.suspendThread(testedThreadID);

    // Compose the ForceEarlyReturn command
    CommandPacket forceEarlyReturnPacket = new CommandPacket(
            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
            JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
    forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
    forceEarlyReturnPacket.setNextValueAsValue(new Value(Tag.VOID_TAG, 0));

    // Perform the command
    logWriter.println("==> Perform " + thisCommandName);
    ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
            .performCommand(forceEarlyReturnPacket);
    forceEarlyReturnPacket = null;

    checkReplyPacket(forceEarlyReturnReply,
            "ThreadReference::ForceEarlyReturn command");

    // Resume the thread
    logWriter.println("==> testedThreadID = " + testedThreadID);
    logWriter.println("==> resume testedThread...");
    debuggeeWrapper.vmMirror.resumeThread(testedThreadID);

    String isBreak = synchronizer.receiveMessage();
    // Check the early returned value
    if (!isBreak.equals("TRUE")) {
        printErrorAndFail(thisCommandName
                + "returned value is not void set by ForceEarlyReturn command");
    }
    logWriter
            .println("==> CHECK: PASSED: returned value does set by ForceEarlyReturn command.");
    logWriter.println("==> Returned value: " + "void");

    synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:74,代码来源:ForceEarlyReturn005Test.java

示例6: testForceEarlyReturn_ReturnObject

import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; //导入方法依赖的package包/类
/**
 * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
 * At first the test starts ForceEarlyReturnDebuggee and send it the thread
 * name through which to start a specific thread. Then the test performs the
 * ThreadReference.ForceEarlyReturn command for the tested thread and gets
 * the returned value of the called method. The returned value should be
 * equal to the value which is used in ForceEarlyReturn Command. In this
 * testcase, an Object value is returned.
 */
public void testForceEarlyReturn_ReturnObject() {
    String thisTestName = "testForceEarlyReturn_ReturnObject";
    logWriter.println("==> " + thisTestName + " for " + thisCommandName
            + ": START...");
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    if (!isCapability()) {
        logWriter
                .println("##WARNING: this VM dosn't possess capability:canForceEarlyReturn");
        return;
    }

    // Get test object id
    long testObjID = getObjectID();
    logWriter.println("==> test object id is: " + testObjID);

    // Tell debuggee to start a thread named THREAD_OBJECT
    synchronizer.sendMessage(ForceEarlyReturnDebuggee.THREAD_OBJECT);

    // Wait until the func_Object is processing.
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    // Getting ID of the tested thread
    logWriter.println("==> testedThreadName = "
            + ForceEarlyReturnDebuggee.THREAD_OBJECT);
    logWriter.println("==> Get testedThreadID...");
    long testedThreadID = debuggeeWrapper.vmMirror
            .getThreadID(ForceEarlyReturnDebuggee.THREAD_OBJECT);
    logWriter.println("==> Get testedThreadID is" + testedThreadID);

    // Suspend the VM before perform command
    logWriter.println("==> testedThreadID = " + testedThreadID);
    logWriter.println("==> suspend testedThread...");
    debuggeeWrapper.vmMirror.suspendThread(testedThreadID);

    // Compose the ForceEarlyReturn command
    CommandPacket forceEarlyReturnPacket = new CommandPacket(
            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
            JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
    forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
    forceEarlyReturnPacket.setNextValueAsValue(new Value(Tag.OBJECT_TAG,
            testObjID));

    // Perform the command
    logWriter.println("==> Perform " + thisCommandName);
    ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
            .performCommand(forceEarlyReturnPacket);
    forceEarlyReturnPacket = null;

    checkReplyPacket(forceEarlyReturnReply,
            "ThreadReference::ForceEarlyReturn command");

    // Resume the thread
    logWriter.println("==> testedThreadID = " + testedThreadID);
    logWriter.println("==> resume testedThread...");
    debuggeeWrapper.vmMirror.resumeThread(testedThreadID);

    String isTestObj = synchronizer.receiveMessage();
    // Check the early returned value
    if (!isTestObj.equals("TRUE")) {
        printErrorAndFail(thisCommandName
                + "returned value is not test object set by ForceEarlyReturn command");
    }
    logWriter
            .println("==> CHECK: PASSED: returned value does set by ForceEarlyReturn command.");
    logWriter.println("==> Returned value: " + "void");

    synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:79,代码来源:ForceEarlyReturn006Test.java

示例7: testForceEarlyReturn_ReturnLong

import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; //导入方法依赖的package包/类
/**
 * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
 * At first the test starts ForceEarlyReturnDebuggee and send it the thread
 * name through which to start a specific thread. Then the test performs the
 * ThreadReference.ForceEarlyReturn command for the tested thread and gets
 * the returned value of the called method. The returned value should be
 * equal to the value which is used in ForceEarlyReturn Command. In this
 * testcase, an Long value is returned.
 */
public void testForceEarlyReturn_ReturnLong() {
    String thisTestName = "testForceEarlyReturn_ReturnLong";
    logWriter.println("==> " + thisTestName + " for " + thisCommandName
            + ": START...");
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    if (!isCapability()) {
        logWriter
                .println("##WARNING: this VM dosn't possess capability:canForceEarlyReturn");
        return;
    }
    // Tell debuggee to start a thread named THREAD_LONG
    synchronizer.sendMessage(ForceEarlyReturnDebuggee.THREAD_LONG);

    // The thread is ready
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    // Getting ID of the tested thread
    logWriter.println("==> testedThreadName = "
            + ForceEarlyReturnDebuggee.THREAD_LONG);
    logWriter.println("==> Get testedThreadID...");
    long testedThreadID = debuggeeWrapper.vmMirror
            .getThreadID(ForceEarlyReturnDebuggee.THREAD_LONG);
    logWriter.println("==> Get testedThreadID is" + testedThreadID);


    // Compose the ForceEarlyReturn command
    CommandPacket forceEarlyReturnPacket = new CommandPacket(
            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
            JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
    forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
    forceEarlyReturnPacket.setNextValueAsValue(new Value(EXPECTED_LONG));

    // Perform the command
    logWriter.println("==> Perform " + thisCommandName);
    ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
            .performCommand(forceEarlyReturnPacket);
    forceEarlyReturnPacket = null;

    checkReplyPacket(forceEarlyReturnReply,
            "ThreadReference::ForceEarlyReturn command");

    // Resume the thread
    logWriter.println("==> testedThreadID = " + testedThreadID);
    logWriter.println("==> resume testedThread...");
    debuggeeWrapper.vmMirror.resumeThread(testedThreadID);

    String actualValue = synchronizer.receiveMessage();
    // Check the early returned value
    if (!actualValue.equals(new Long(EXPECTED_LONG).toString())) {
        printErrorAndFail(thisCommandName
                + "returned value is not set by ForceEarlyReturn command"
                + " expected:<" + EXPECTED_LONG + "> but was:<"
                + actualValue + ">");
    }
    logWriter
            .println("==> CHECK: PASSED: returned value does set by ForceEarlyReturn command.");
    logWriter.println("==> Returned value: " + actualValue);

    synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:71,代码来源:ForceEarlyReturn002Test.java

示例8: RunTestForceEarlyReturn

import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; //导入方法依赖的package包/类
public void RunTestForceEarlyReturn() {
    logWriter.println("==> " + thisTestName + " for " + thisCommandName
            + ": START...");
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    if (!isCapability()) {
        logWriter
                .println("##WARNING: this VM dosn't possess capability: canForceEarlyReturn");
        return;
    }
    // Tell debuggee to start a thread
    synchronizer.sendMessage(testThreadName);

    // Wait until the func_Int is processing.
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    // Getting ID of the tested thread
    logWriter.println("==> testedThreadName = " + testThreadName);
    logWriter.println("==> Get testedThreadID...");
    long testedThreadID = debuggeeWrapper.vmMirror
            .getThreadID(testThreadName);
    logWriter.println("==> Get testedThreadID is" + testedThreadID);

    // Suspend the VM before perform command
    logWriter.println("==> testedThreadID = " + testedThreadID);
    logWriter.println("==> suspend testedThread...");
    debuggeeWrapper.vmMirror.suspendThread(testedThreadID);

    // Compose the ForceEarlyReturn command
    CommandPacket forceEarlyReturnPacket = new CommandPacket(
            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
            JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
    forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
    forceEarlyReturnPacket.setNextValueAsValue(expectedValue);

    // Perform the command
    logWriter.println("==> Perform " + thisCommandName);
    ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
            .performCommand(forceEarlyReturnPacket);
    forceEarlyReturnPacket = null;

    checkReplyPacket(forceEarlyReturnReply,
            "ThreadReference::ForceEarlyReturn command");

    // Resume the thread
    logWriter.println("==> testedThreadID = " + testedThreadID);
    logWriter.println("==> resume testedThread...");
    debuggeeWrapper.vmMirror.resumeThread(testedThreadID);

    String actualValue = synchronizer.receiveMessage();
    // Check the early returned value
    if (!actualValue.equals(toString(expectedValue))) {
        printErrorAndFail(thisCommandName
                + "returned value is not set by ForceEarlyReturn command"
                + " expected:<" + expectedValue.toString() + "> but was:<"
                + actualValue + ">");
    }
    logWriter
            .println("==> CHECK: PASSED: returned value does set by ForceEarlyReturn command.");
    logWriter.println("==> Returned value: " + actualValue);

    synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:64,代码来源:ForceEarlyReturnTest.java

示例9: testForceEarlyReturn_NotSuspended

import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; //导入方法依赖的package包/类
/**
 * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
 * At first the test starts ForceEarlyReturnDebuggee and send it the thread
 * name through which to start a specific thread. Then the test performs the
 * ThreadReference.ForceEarlyReturn command for the tested thread without
 * suspending the VM. In this testcase, THREAD_NOT_SUSPENDED exception is returned.
 */
public void testForceEarlyReturn_NotSuspended() {
    thisTestName = "testForceEarlyReturn_NotSuspended";
    testThreadName = "test";
    expectedValue = new Value(Tag.VOID_TAG, 0);

    logWriter.println("==> " + thisTestName + " for " + thisCommandName
            + ": START...");
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    if (!isCapability()) {
        logWriter
                .println("##WARNING: this VM dosn't possess capability: canForceEarlyReturn");
        return;
    }
    // Tell debuggee to start a thread
    synchronizer.sendMessage(testThreadName);

    // Wait thread signal.
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    // Getting ID of the tested thread
    logWriter.println("==> testedThreadName = " + testThreadName);
    logWriter.println("==> Get testedThreadID...");
    long testedThreadID = debuggeeWrapper.vmMirror
            .getThreadID(testThreadName);
    logWriter.println("==> Get testedThreadID is" + testedThreadID);

    // Compose the ForceEarlyReturn command
    CommandPacket forceEarlyReturnPacket = new CommandPacket(
            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
            JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
    forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
    forceEarlyReturnPacket.setNextValueAsValue(expectedValue);

    // Perform the command
    logWriter.println("==> Perform " + thisCommandName);
    ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
            .performCommand(forceEarlyReturnPacket);
    forceEarlyReturnPacket = null;

    short errorCode = forceEarlyReturnReply.getErrorCode();
    if (errorCode != JDWPConstants.Error.NONE) {
        if (errorCode == JDWPConstants.Error.THREAD_NOT_SUSPENDED) {
            logWriter
                    .println("=> CHECK PASSED: Expected error (THREAD_NOT_SUSPENDED) is returned");
            synchronizer.sendMessage("ThreadExit");
            synchronizer
                    .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
            return;
        }
    }
    printErrorAndFail(thisCommandName
            + " should throw exception when VM is not suspended.");

}
 
开发者ID:shannah,项目名称:cn1,代码行数:63,代码来源:ForceEarlyReturnTest.java

示例10: testForceEarlyReturn_ReturnFloat

import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; //导入方法依赖的package包/类
/**
 * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
 * At first the test starts ForceEarlyReturnDebuggee and send it the thread
 * name through which to start a specific thread. Then the test performs the
 * ThreadReference.ForceEarlyReturn command for the tested thread and gets
 * the returned value of the called method. The returned value should be
 * equal to the value which is used in ForceEarlyReturn Command. In this
 * testcase, an Float value is returned.
 */
public void testForceEarlyReturn_ReturnFloat() {
    String thisTestName = "testForceEarlyReturn_ReturnFloat";
    logWriter.println("==> " + thisTestName + " for " + thisCommandName
            + ": START...");
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    if (!isCapability()) {
        logWriter
                .println("##WARNING: this VM dosn't possess capability:canForceEarlyReturn");
        return;
    }
    // Tell debuggee to start a thread named THREAD_FLOAT
    synchronizer.sendMessage(ForceEarlyReturnDebuggee.THREAD_FLOAT);

    // Wait until the func_FLOAT is processing.
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    // Getting ID of the tested thread
    logWriter.println("==> testedThreadName = "
            + ForceEarlyReturnDebuggee.THREAD_FLOAT);
    logWriter.println("==> Get testedThreadID...");
    long testedThreadID = debuggeeWrapper.vmMirror
            .getThreadID(ForceEarlyReturnDebuggee.THREAD_FLOAT);
    logWriter.println("==> Get testedThreadID is" + testedThreadID);

    // Suspend the VM before perform command
    logWriter.println("==> testedThreadID = " + testedThreadID);
    logWriter.println("==> suspend testedThread...");
    debuggeeWrapper.vmMirror.suspendThread(testedThreadID);

    // Compose the ForceEarlyReturn command
    CommandPacket forceEarlyReturnPacket = new CommandPacket(
            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
            JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
    forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
    forceEarlyReturnPacket.setNextValueAsValue(new Value(EXPECTED_FLOAT));

    // Perform the command
    logWriter.println("==> Perform " + thisCommandName);
    ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
            .performCommand(forceEarlyReturnPacket);
    forceEarlyReturnPacket = null;

    checkReplyPacket(forceEarlyReturnReply,
            "ThreadReference::ForceEarlyReturn command");

    // Resume the thread
    logWriter.println("==> testedThreadID = " + testedThreadID);
    logWriter.println("==> resume testedThread...");
    debuggeeWrapper.vmMirror.resumeThread(testedThreadID);

    String actualValue = synchronizer.receiveMessage();
    // Check the early returned value
    if (!actualValue.equals(new Float(EXPECTED_FLOAT).toString())) {
        printErrorAndFail(thisCommandName
                + "returned value is not set by ForceEarlyReturn command"
                + " expected:<" + EXPECTED_FLOAT + "> but was:<"
                + actualValue + ">");
    }
    logWriter
            .println("==> CHECK: PASSED: returned value does set by ForceEarlyReturn command.");
    logWriter.println("==> Returned value: " + actualValue);

    synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:75,代码来源:ForceEarlyReturn003Test.java

示例11: testForceEarlyReturn_ReturnDouble

import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; //导入方法依赖的package包/类
/**
 * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
 * At first the test starts ForceEarlyReturnDebuggee and send it the thread
 * name through which to start a specific thread. Then the test performs the
 * ThreadReference.ForceEarlyReturn command for the tested thread and gets
 * the returned value of the called method. The returned value should be
 * equal to the value which is used in ForceEarlyReturn Command. In this
 * testcase, an Double value is returned.
 */
public void testForceEarlyReturn_ReturnDouble() {
    String thisTestName = "testForceEarlyReturn_ReturnDouble";
    logWriter.println("==> " + thisTestName + " for " + thisCommandName
            + ": START...");
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    if (!isCapability()) {
        logWriter
                .println("##WARNING: this VM dosn't possess capability:canForceEarlyReturn");
        return;
    }
    // Tell debuggee to start a thread named THREAD_DOUBLE
    synchronizer.sendMessage(ForceEarlyReturnDebuggee.THREAD_DOUBLE);

    // Wait until the func_Double is processing.
    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);

    // Getting ID of the tested thread
    logWriter.println("==> testedThreadName = "
            + ForceEarlyReturnDebuggee.THREAD_DOUBLE);
    logWriter.println("==> Get testedThreadID...");
    long testedThreadID = debuggeeWrapper.vmMirror
            .getThreadID(ForceEarlyReturnDebuggee.THREAD_DOUBLE);
    logWriter.println("==> Get testedThreadID is" + testedThreadID);

    // Suspend the VM before perform command
    logWriter.println("==> testedThreadID = " + testedThreadID);
    logWriter.println("==> suspend testedThread...");
    debuggeeWrapper.vmMirror.suspendThread(testedThreadID);

    // Compose the ForceEarlyReturn command
    CommandPacket forceEarlyReturnPacket = new CommandPacket(
            JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
            JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
    forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
    forceEarlyReturnPacket.setNextValueAsValue(new Value(EXPECTED_DOUBLE));

    // Perform the command
    logWriter.println("==> Perform " + thisCommandName);
    ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
            .performCommand(forceEarlyReturnPacket);
    forceEarlyReturnPacket = null;

    checkReplyPacket(forceEarlyReturnReply,
            "ThreadReference::ForceEarlyReturn command");

    // Resume the thread
    logWriter.println("==> testedThreadID = " + testedThreadID);
    logWriter.println("==> resume testedThread...");
    debuggeeWrapper.vmMirror.resumeThread(testedThreadID);

    String actualValue = synchronizer.receiveMessage();
    // Check the early returned value
    if (!actualValue.equals(new Double(EXPECTED_DOUBLE).toString())) {
        printErrorAndFail(thisCommandName
                + "returned value is not set by ForceEarlyReturn command"
                + " expected:<" + EXPECTED_DOUBLE + "> but was:<"
                + actualValue + ">");
    }
    logWriter
            .println("==> CHECK: PASSED: returned value does set by ForceEarlyReturn command.");
    logWriter.println("==> Returned value: " + actualValue);

    synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);

}
 
开发者ID:shannah,项目名称:cn1,代码行数:76,代码来源:ForceEarlyReturn004Test.java

示例12: makeNewInstance

import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; //导入方法依赖的package包/类
protected TaggedObject makeNewInstance(long typeID, long threadID,
        long constructorID, int testNumber) {
    CommandPacket packet = new CommandPacket(
            JDWPCommands.ClassTypeCommandSet.CommandSetID,
            JDWPCommands.ClassTypeCommandSet.NewInstanceCommand);
    packet.setNextValueAsClassID(typeID);
    packet.setNextValueAsThreadID(threadID);
    packet.setNextValueAsMethodID(constructorID);
    if ( testNumber == 1 ) {
        packet.setNextValueAsInt(1); // number of parameters
        packet.setNextValueAsValue(new Value(false));
    }
    if ( testNumber == 2 ) {
        packet.setNextValueAsInt(0); // number of parameters
    }
    packet.setNextValueAsInt(0);
    logWriter.println("\nSend ClassType.NewInstance");
    ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
    checkReplyPacket(reply, "ClassType::NewInstance command");

    TaggedObject newObject = reply.getNextValueAsTaggedObject();
    logWriter.println(" ClassType.NewInstance: newObject.tag="
            + newObject.tag + " newObject.objectID=" + newObject.objectID);

    TaggedObject exception = reply.getNextValueAsTaggedObject();
    logWriter.println(" ClassType.NewInstance: exception.tag="
            + exception.tag + " exception.objectID=" + exception.objectID);

    assertTrue("newObject must be != null", newObject != null);
    assertTrue("newObject.objectID must be != 0", newObject.objectID != 0);
    assertEquals("Invalid object tag,", JDWPConstants.Tag.OBJECT_TAG, newObject.tag
            , JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG)
            , JDWPConstants.Tag.getName(newObject.tag));

    assertTrue("exception must be != null", exception != null);
    assertTrue("exception.objectID must be == 0", exception.objectID == 0);
    assertEquals("Invalid exception.tag,", JDWPConstants.Tag.OBJECT_TAG, exception.tag
            , JDWPConstants.Tag.getName(JDWPConstants.Tag.OBJECT_TAG)
            , JDWPConstants.Tag.getName(exception.tag));

    assertAllDataRead(reply);
    return newObject;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:44,代码来源:InvokeMethodTest.java


注:本文中的org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket.setNextValueAsValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。