Implement ReferenceType.Instances.
Change-Id: I6a72fc4c748e7041fedcb615eca2b86b1f28bb63
diff --git a/src/jdwp/jdwp_handler.cc b/src/jdwp/jdwp_handler.cc
index f68e560..86ecffe 100644
--- a/src/jdwp/jdwp_handler.cc
+++ b/src/jdwp/jdwp_handler.cc
@@ -649,6 +649,30 @@
return Dbg::OutputDeclaredMethods(refTypeId, false, pReply);
}
+static JdwpError RT_Instances(JdwpState*, const uint8_t* buf, int, ExpandBuf* reply)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+ RefTypeId class_id = ReadRefTypeId(&buf);
+ int32_t max_count = Read4BE(&buf);
+ if (max_count < 0) {
+ return ERR_ILLEGAL_ARGUMENT;
+ }
+
+ std::vector<ObjectId> instances;
+ JdwpError rc = Dbg::GetInstances(class_id, max_count, instances);
+ if (rc != ERR_NONE) {
+ return rc;
+ }
+
+ expandBufAdd4BE(reply, instances.size());
+ for (size_t i = 0; i < instances.size(); ++i) {
+ rc = WriteTaggedObject(reply, instances[i]);
+ if (rc != ERR_NONE) {
+ return rc;
+ }
+ }
+ return ERR_NONE;
+}
+
/*
* Return the immediate superclass of a class.
*/
@@ -1616,7 +1640,7 @@
{ 2, 13, RT_SignatureWithGeneric, "ReferenceType.SignatureWithGeneric" },
{ 2, 14, RT_FieldsWithGeneric, "ReferenceType.FieldsWithGeneric" },
{ 2, 15, RT_MethodsWithGeneric, "ReferenceType.MethodsWithGeneric" },
- { 2, 16, NULL, "ReferenceType.Instances" },
+ { 2, 16, RT_Instances, "ReferenceType.Instances" },
{ 2, 17, NULL, "ReferenceType.ClassFileVersion" },
{ 2, 18, NULL, "ReferenceType.ConstantPool" },