本文整理汇总了Java中org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket.getErrorCode方法的典型用法代码示例。如果您正苦于以下问题:Java ReplyPacket.getErrorCode方法的具体用法?Java ReplyPacket.getErrorCode怎么用?Java ReplyPacket.getErrorCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket
的用法示例。
在下文中一共展示了ReplyPacket.getErrorCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLineTable
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
/**
* Returns line number information for the method, if present.
*
* @param refType
* The class ID
* @param methodID
* The method ID
* @return ReplyPacket for corresponding command.
*/
public final ReplyPacket getLineTable(long refType, long methodID) {
CommandPacket command = new CommandPacket(
JDWPCommands.MethodCommandSet.CommandSetID,
JDWPCommands.MethodCommandSet.LineTableCommand);
command.setNextValueAsReferenceTypeID(refType);
command.setNextValueAsMethodID(methodID);
// ReplyPacket reply =
// debuggeeWrapper.vmMirror.checkReply(debuggeeWrapper.vmMirror.performCommand(command));
// it is impossible to obtain line table information from native
// methods, so reply checking is not performed
ReplyPacket reply = performCommand(command);
if (reply.getErrorCode() != JDWPConstants.Error.NONE) {
if (reply.getErrorCode() == JDWPConstants.Error.NATIVE_METHOD) {
return reply;
}
}
return checkReply(reply);
}
示例2: getLineNumber
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
/**
* Returns a source line number according to a corresponding line code index
* in a method's line table.
*
* @param classID
* The class object ID.
* @param methodID
* The method ID.
* @param codeIndex
* The line code index.
* @return An integer line number.
*/
public final int getLineNumber(long classID, long methodID, long codeIndex) {
int lineNumber = -1;
ReplyPacket reply = getLineTable(classID, methodID);
if (reply.getErrorCode() != JDWPConstants.Error.NONE) {
return lineNumber;
}
reply.getNextValueAsLong(); // start line index, is not used
reply.getNextValueAsLong(); // end line index, is not used
int lines = reply.getNextValueAsInt();
for (int i = 0; i < lines; i++) {
long lineCodeIndex = reply.getNextValueAsLong();
lineNumber = reply.getNextValueAsInt();
if (lineCodeIndex == codeIndex) {
break;
}
if (lineCodeIndex > codeIndex) {
--lineNumber;
break;
}
}
return lineNumber;
}
示例3: getLineCodeIndex
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
/**
* Returns a line code index according to a corresponding line number in a
* method's line table.
*
* @param classID
* The class object ID.
* @param methodID
* The method ID.
* @param lineNumber
* A source line number.
* @return An integer representing the line code index.
*/
public final long getLineCodeIndex(long classID, long methodID,
int lineNumber) {
ReplyPacket reply = getLineTable(classID, methodID);
if (reply.getErrorCode() != JDWPConstants.Error.NONE) {
return -1L;
}
reply.getNextValueAsLong(); // start line index, is not used
reply.getNextValueAsLong(); // end line index, is not used
int lines = reply.getNextValueAsInt();
for (int i = 0; i < lines; i++) {
long lineCodeIndex = reply.getNextValueAsLong();
if (lineNumber == reply.getNextValueAsInt()) {
return lineCodeIndex;
}
}
return -1L;
}
示例4: getFramesCount
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
private int getFramesCount(long threadID) {
logWriter.println("getting frames of the thread");
short err;
// getting frames of the thread
CommandPacket packet = new CommandPacket(
JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
JDWPCommands.ThreadReferenceCommandSet.FramesCommand);
packet.setNextValueAsThreadID(threadID);
packet.setNextValueAsInt(0);
packet.setNextValueAsInt(-1);
ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
err = reply.getErrorCode();
if ( err != JDWPConstants.Error.NONE) {
logWriter.println("\tthreadID=" + threadID
+ " - " + JDWPConstants.Error.getName(err));
return 0;
}
int framesCount = reply.getNextValueAsInt();
return framesCount;
}
示例5: getSourceFile
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
public String getSourceFile() {
// TODO(shertz) support JSR-45
Location location = getLocation();
CommandPacket sourceFileCommand = new CommandPacket(
JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
JDWPCommands.ReferenceTypeCommandSet.SourceFileCommand);
sourceFileCommand.setNextValueAsReferenceTypeID(location.classID);
ReplyPacket replyPacket = getMirror().performCommand(sourceFileCommand);
if (replyPacket.getErrorCode() != 0) {
return null;
} else {
return replyPacket.getNextValueAsString();
}
}
示例6: setBreakpointAtMethodBegin
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
/**
* Sets breakpoint at the beginning of method with name <i>methodName</i>.
*
* @param classID
* id of class with required method
* @param methodName
* name of required method
* @return requestID id of request
*/
public long setBreakpointAtMethodBegin(long classID, String methodName) {
long requestID;
long methodID = getMethodID(classID, methodName);
ReplyPacket lineTableReply = getLineTable(classID, methodID);
if (lineTableReply.getErrorCode() != JDWPConstants.Error.NONE) {
throw new TestErrorException(
"Command getLineTable returned error code: "
+ lineTableReply.getErrorCode()
+ " - "
+ JDWPConstants.Error.getName(lineTableReply
.getErrorCode()));
}
lineTableReply.getNextValueAsLong();
// Lowest valid code index for the method
lineTableReply.getNextValueAsLong();
// Highest valid code index for the method
// int numberOfLines =
lineTableReply.getNextValueAsInt();
long lineCodeIndex = lineTableReply.getNextValueAsLong();
// set breakpoint inside checked method
Location breakpointLocation = new Location(JDWPConstants.TypeTag.CLASS,
classID, methodID, lineCodeIndex);
ReplyPacket reply = setBreakpoint(breakpointLocation);
checkReply(reply);
requestID = reply.getNextValueAsInt();
return requestID;
}
示例7: getVariableTable
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
/**
* Returns variable information for the method
*
* @param classID
* The class ID
* @param methodID
* The method ID
* @return A list containing all variables (arguments and locals) declared
* within the method.
*/
public final List getVariableTable(long classID, long methodID) {
CommandPacket command = new CommandPacket(
JDWPCommands.MethodCommandSet.CommandSetID,
JDWPCommands.MethodCommandSet.VariableTableCommand);
command.setNextValueAsReferenceTypeID(classID);
command.setNextValueAsMethodID(methodID);
// ReplyPacket reply =
// debuggeeWrapper.vmMirror.checkReply(debuggeeWrapper.vmMirror.performCommand(command));
ReplyPacket reply = performCommand(command);
if (reply.getErrorCode() == JDWPConstants.Error.ABSENT_INFORMATION
|| reply.getErrorCode() == JDWPConstants.Error.NATIVE_METHOD) {
return null;
}
checkReply(reply);
reply.getNextValueAsInt(); // argCnt, is not used
int slots = reply.getNextValueAsInt();
if (slots == 0) {
return null;
}
ArrayList<Variable> vars = new ArrayList<Variable>(slots);
for (int i = 0; i < slots; i++) {
Variable var = new Frame().new Variable();
var.setCodeIndex(reply.getNextValueAsLong());
var.setName(reply.getNextValueAsString());
var.setSignature(reply.getNextValueAsString());
var.setLength(reply.getNextValueAsInt());
var.setSlot(reply.getNextValueAsInt());
vars.add(var);
}
return vars;
}
示例8: checkReplyPacket
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
/**
* Helper for checking reply packet error code. If reply packet does not
* have unexpected error - returns true. If reply packet has got unexpected
* error: If failSign param = true - calls junit fail. Otherwise prints
* message about error and returns false.
*
* @param reply -
* returned from debuggee packet
* @param message -
* additional message
* @param expected -
* array of expected error codes
* @param failSign -
* defines to call junit fail or not
* @return true if unexpected errors are not found, or false otherwise
*/
protected boolean checkReplyPacket(ReplyPacket reply, String message,
int[] expected, boolean failSign) {
// check reply code against expected
int errorCode = reply.getErrorCode();
for (int i = 0; i < expected.length; i++) {
if (reply.getErrorCode() == expected[i]) {
return true; // OK
}
}
// replay code validation failed
// start error message composition
if (null == message) {
message = "";
} else {
message = message + ", ";
}
// format error message
if (expected.length == 1 && JDWPConstants.Error.NONE == expected[0]) {
message = message + "Error Code:<" + errorCode + "("
+ JDWPConstants.Error.getName(errorCode) + ")>";
} else {
message = message + "Unexpected error code:<" + errorCode + "("
+ JDWPConstants.Error.getName(errorCode) + ")>"
+ ", Expected error code"
+ (expected.length == 1 ? ":" : "s:");
for (int i = 0; i < expected.length; i++) {
message = message + (i > 0 ? ",<" : "<") + expected[i] + "("
+ JDWPConstants.Error.getName(expected[i]) + ")>";
}
}
if (failSign) {
printErrorAndFail(message);
}
logWriter.printError(message);
return false;
}
示例9: testSetDefaultStratum001
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
/**
* This testcase exercises VirtualMachine.SetDefaultStratum command.
* <BR>At first the test starts HelloWorld debuggee.
* <BR>Then the test checks that VirtualMachine.SetDefaultStratum command runs
* without any error or returns NOT_IMPLEMENTED error.
* Any other error is considered as test' failure.
*/
public void testSetDefaultStratum001() {
String thisTestName = "testSetDefaultStratum001";
//check capability, relevant for this test
logWriter.println("=> Check capability: canSetDefaultStratum");
debuggeeWrapper.vmMirror.capabilities();
boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canSetDefaultStratum;
if (!isCapability) {
logWriter.println("##WARNING: this VM dosn't possess capability: canSetDefaultStratum");
return;
}
logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
logWriter.println("=> CHECK1: send " + thisCommandName + " and check reply for ERROR...");
String stratumID = "C++";
CommandPacket checkedCommand = new CommandPacket(
JDWPCommands.VirtualMachineCommandSet.CommandSetID,
JDWPCommands.VirtualMachineCommandSet.SetDefaultStratumCommand);
checkedCommand.setNextValueAsString(stratumID);
ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
checkedCommand = null;
short errorCode = checkedReply.getErrorCode();
if ( errorCode != JDWPConstants.Error.NONE ) {
if ( errorCode != JDWPConstants.Error.NOT_IMPLEMENTED ) {
printErrorAndFail(thisCommandName
+ " returns unexpected ERROR = " + errorCode
+ "(" + JDWPConstants.Error.getName(errorCode) + ")");
} else {
logWriter.println("=> CHECK PASSED: Expected error (NOT_IMPLEMENTED) is returned");
}
} else {
logWriter.println
("=> CHECK PASSED: No any error is received");
}
}
示例10: testInstanceCounts_IllegalArgument
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
/**
* This testcase exercises ReferenceType.InstanceCounts command. <BR>
* Compose a InstanceCounts command with negative reference types count
* The vm should throw a ILLEGAL_ARGUMENT exception.
*/
public void testInstanceCounts_IllegalArgument() {
String thisTestName = "testInstanceCounts_IllegalArgument";
if (!isCapability()) {
logWriter.println("##WARNING: this VM dosn't possess capability: canGetInstanceInfo");
return;
}
int refTypesCount = -1;
logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
// Compose InstanceCounts commnad
CommandPacket InstanceCountsCommand = new CommandPacket(
JDWPCommands.VirtualMachineCommandSet.CommandSetID,
JDWPCommands.VirtualMachineCommandSet.InstanceCountsCommand);
InstanceCountsCommand.setNextValueAsInt(refTypesCount);
InstanceCountsCommand.setNextValueAsReferenceTypeID(0);
// Perform InstanceCounts command and attain reply package
ReplyPacket checkedReply = debuggeeWrapper.vmMirror
.performCommand(InstanceCountsCommand);
InstanceCountsCommand = null;
short errorCode = checkedReply.getErrorCode();
if (errorCode != JDWPConstants.Error.NONE) {
if (errorCode == JDWPConstants.Error.NOT_IMPLEMENTED) {
logWriter.println("=> CHECK PASSED: Expected error (NOT_IMPLEMENTED) is returned");
return;
}
else if(errorCode == JDWPConstants.Error.ILLEGAL_ARGUMENT) {
logWriter.println("=> CHECK PASSED: Expected error (ILLEGAL_ARGUMENT) is returned");
return;
}
}
printErrorAndFail(thisCommandName + " should throw ILLEGAL_ARGUMENT exception when refTypesCount is negative.");
}
示例11: testInterrupt001
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
/**
* This testcase exercises ThreadReference.Interrupt command.
* <BR>At first the test starts InterruptDebuggee which runs
* the tested thread 'TESTED_THREAD' and blocks it in invocation of
* the 'wait()' method.
* <BR> Then the tests performs the ThreadReference.Interrupt command
* for tested thread.
* <BR>After sending Interrupt command, the test waits signals via synchronization
* channel that 'InterruptedException' was thrown.
*/
public void testInterrupt001() {
synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
// getting ID of the tested thread
logWriter.println("get thread ID");
long threadID =
debuggeeWrapper.vmMirror.getThreadID(InterruptDebuggee.TESTED_THREAD);
// getting the thread group ID
CommandPacket packet = new CommandPacket(
JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
JDWPCommands.ThreadReferenceCommandSet.InterruptCommand);
packet.setNextValueAsThreadID(threadID);
logWriter.println("send \"Interrupt\" command");
ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
short err = reply.getErrorCode();
logWriter.println("error = " + err);
if (err == JDWPConstants.Error.NONE) {
Thread thrd = new RecvThread();
thrd.start();
try {
thrd.join(settings.getTimeout());
} catch(InterruptedException e) {
}
}
if (!isReceived) {
printErrorAndFail(waitForString + " is not received");
} else {
logWriter.println(waitForString + " is received");
}
synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
}
示例12: getFrames
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
private Vector getFrames(int startFrame, int length) {
Vector<FrameStruct> frames = new Vector<FrameStruct>();
logWriter.println("startFrame=" + startFrame
+ "; length=" + length);
// getting frames of the thread
CommandPacket packet = new CommandPacket(
JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
JDWPCommands.ThreadReferenceCommandSet.FramesCommand);
packet.setNextValueAsThreadID(threadID);
packet.setNextValueAsInt(startFrame);
packet.setNextValueAsInt(length);
ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
err = reply.getErrorCode();
if ( err != JDWPConstants.Error.NONE) {
logWriter.println("\tthreadID=" + threadID
+ " - " + JDWPConstants.Error.getName(err));
return null;
}
int framesCount = reply.getNextValueAsInt();
long frameID;
Location loc;
logWriter.println("framesCount=" + framesCount);
for (int j = 0; j < framesCount; j++) {
frameID = reply.getNextValueAsFrameID();
loc = reply.getNextValueAsLocation();
frames.add(new FrameStruct(frameID, loc));
}
return frames;
}
示例13: testOwnedMonitorsStackDepthInfo_Unsuspended
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
public void testOwnedMonitorsStackDepthInfo_Unsuspended() {
String thisTestName = "testOwnedMonitorsStackDepthInfo";
logWriter.println("==> " + thisTestName + " for " + thisCommandName
+ ": START...");
synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
if (!isCapability()) {
logWriter
.println("##WARNING: this VM dosn't possess capability: OwnedMonitorsStackDepthInfo");
return;
}
// Getting ID of the tested thread
logWriter.println("==> testedThreadName = "
+ OwnedMonitorsStackDepthInfoDebuggee.TESTED_THREAD);
logWriter.println("==> Get testedThreadID...");
long testedThreadID = debuggeeWrapper.vmMirror
.getThreadID(OwnedMonitorsStackDepthInfoDebuggee.TESTED_THREAD);
// Compose the OwnedMonitorsStackDepthInfo command
CommandPacket stackDepthPacket = new CommandPacket(
JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
JDWPCommands.ThreadReferenceCommandSet.OwnedMonitorsStackDepthInfoCommand);
stackDepthPacket.setNextValueAsThreadID(testedThreadID);
// Perform the command and attain the reply package
ReplyPacket checkedReply = debuggeeWrapper.vmMirror
.performCommand(stackDepthPacket);
short errorCode = checkedReply.getErrorCode();
if (errorCode != JDWPConstants.Error.NONE) {
if (errorCode == JDWPConstants.Error.THREAD_NOT_SUSPENDED) {
logWriter.println("=> CHECK PASSED: Expected error (THREAD_NOT_SUSPENDED) is returned");
return;
}
}
printErrorAndFail(thisCommandName + " should throw exception when VM is not suspended.");
}
示例14: setStaticIntField
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
/**
* Helper for setting static int field in class with new value.
*
* @param classSignature -
* String defining signature of class
* @param fieldName -
* String defining field name in specified class
* @param newValue -
* int value to set for specified field
* @return true, if setting is successfully, or false otherwise
*/
protected boolean setStaticIntField(String classSignature,
String fieldName, int newValue) {
long classID = debuggeeWrapper.vmMirror.getClassID(classSignature);
if (classID == -1) {
logWriter
.println("## setStaticIntField(): Can NOT get classID for class signature = '"
+ classSignature + "'");
return false;
}
long fieldID = debuggeeWrapper.vmMirror.getFieldID(classID, fieldName);
if (fieldID == -1) {
logWriter
.println("## setStaticIntField(): Can NOT get fieldID for field = '"
+ fieldName + "'");
return false;
}
CommandPacket packet = new CommandPacket(
JDWPCommands.ClassTypeCommandSet.CommandSetID,
JDWPCommands.ClassTypeCommandSet.SetValuesCommand);
packet.setNextValueAsReferenceTypeID(classID);
packet.setNextValueAsInt(1);
packet.setNextValueAsFieldID(fieldID);
packet.setNextValueAsInt(newValue);
ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
int errorCode = reply.getErrorCode();
if (errorCode != JDWPConstants.Error.NONE) {
logWriter
.println("## setStaticIntField(): Can NOT set value for field = '"
+ fieldName
+ "' in class = '"
+ classSignature
+ "'; ClassType.SetValues command reurns error = "
+ errorCode);
return false;
}
return true;
}
示例15: testSourceDebugExtension001
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; //导入方法依赖的package包/类
/**
* This testcase exercises ReferenceType.SourceDebugExtension command.
* <BR>The test starts SourceDebugExtensionDebuggee class, requests referenceTypeId
* for this class by VirtualMachine.ClassesBySignature command, then
* performs ReferenceType.SourceDebugExtension command and checks that
* no any unexpected ERROR is returned.
*/
public void testSourceDebugExtension001() {
String thisTestName = "testSourceDebugExtension001";
//check capability, relevant for this test
logWriter.println("=> Check capability: canGetSourceDebugExtension");
debuggeeWrapper.vmMirror.capabilities();
boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canGetSourceDebugExtension;
if (!isCapability) {
logWriter.println("##WARNING: this VM doesn't possess capability: canGetSourceDebugExtension");
return;
}
logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
long refTypeID = getClassIDBySignature(debuggeeSignature);
logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
logWriter.println("=> CHECK: send " + thisCommandName + " and check reply...");
CommandPacket checkedCommand = new CommandPacket(
JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
JDWPCommands.ReferenceTypeCommandSet.SourceDebugExtensionCommand);
checkedCommand.setNextValueAsReferenceTypeID(refTypeID);
ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
checkedCommand = null;
short errorCode = checkedReply.getErrorCode();
switch ( errorCode ) {
case JDWPConstants.Error.NONE:
logWriter.println("=> No any ERROR is returned");
String SourceDebugExtension = checkedReply.getNextValueAsString();
logWriter.println("=> Returned SourceDebugExtension = " + SourceDebugExtension);
break;
case JDWPConstants.Error.NOT_IMPLEMENTED:
logWriter.println("=> ERROR is returned: "+ errorCode
+ "(" + JDWPConstants.Error.getName(errorCode) + ")");
logWriter.println("=> It is possible ERROR");
break;
case JDWPConstants.Error.ABSENT_INFORMATION:
logWriter.println("=> ERROR is returned: "+ errorCode
+ "(" + JDWPConstants.Error.getName(errorCode) + ")");
logWriter.println("=> It is possible ERROR");
break;
default:
logWriter.println("\n## FAILURE: " + thisCommandName + " returns unexpected ERROR = "
+ errorCode + "(" + JDWPConstants.Error.getName(errorCode) + ")");
fail(thisCommandName + " returns unexpected ERROR = "
+ errorCode + "(" + JDWPConstants.Error.getName(errorCode) + ")");
}
assertAllDataRead(checkedReply);
logWriter.println("=> CHECK PASSED: No any unexpected ERROR is returned");
synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
}