ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
DataOutputStream outData = new DataOutputStream(outBytes);
write(this, outData);
writeInt(max, "max instances", outData); //$NON-NLS-1$
JdwpReplyPacket replyPacket = requestVM(
JdwpCommandPacket.RT_INSTANCES, outBytes);
switch (replyPacket.errorCode()) {
case JdwpReplyPacket.INVALID_OBJECT:
case JdwpReplyPacket.INVALID_CLASS:
throw new ObjectCollectedException(
JDIMessages.class_or_object_not_known);
case JdwpReplyPacket.NOT_IMPLEMENTED:
throw new UnsupportedOperationException(
JDIMessages.ReferenceTypeImpl_27);
case JdwpReplyPacket.ILLEGAL_ARGUMENT:
throw new IllegalArgumentException(
JDIMessages.ReferenceTypeImpl_26);
case JdwpReplyPacket.VM_DEAD:
throw new VMDisconnectedException(JDIMessages.vm_dead);
}
defaultReplyErrorHandler(replyPacket.errorCode());
DataInputStream replyData = replyPacket.dataInStream();
int elements = readInt("element count", replyData); //$NON-NLS-1$
if (max > 0 && elements > max) {
elements = max;
}
ArrayList<ObjectReference> list = new ArrayList<ObjectReference>();