Remove mirror:: and ArtMethod deps in utils.{h,cc}
The latest chapter in the ongoing saga of attempting to dump a DEX
file without having to start a whole runtime instance. This episode
finds us removing references to ArtMethod/ArtField/mirror.
One aspect of this change that I would like to call out specfically
is that the utils versions of the "Pretty*" functions all were written
to accept nullptr as an argument. I have split these functions up as
follows:
1) an instance method, such as PrettyClass that obviously requires
this != nullptr.
2) a static method, that behaves the same way as the util method, but
calls the instance method if p != nullptr.
This requires using a full class qualifier for the static methods,
which isn't exactly beautiful. I have tried to remove as many cases
as possible where it was clear p != nullptr.
Bug: 22322814
Test: test-art-host
Change-Id: I21adee3614aa697aa580cd1b86b72d9206e1cb24
diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc
index 7e92c53..8cfb60e 100644
--- a/runtime/mirror/object.cc
+++ b/runtime/mirror/object.cc
@@ -266,7 +266,7 @@
}
}
LOG(FATAL) << "Failed to find field for assignment to " << reinterpret_cast<void*>(this)
- << " of type " << PrettyDescriptor(c) << " at offset " << field_offset;
+ << " of type " << c->PrettyDescriptor() << " at offset " << field_offset;
UNREACHABLE();
}
@@ -275,5 +275,24 @@
: ArtField::FindInstanceFieldWithOffset(GetClass(), offset.Uint32Value());
}
+std::string Object::PrettyTypeOf(ObjPtr<mirror::Object> obj) {
+ if (obj == nullptr) {
+ return "null";
+ }
+ return obj->PrettyTypeOf();
+}
+
+std::string Object::PrettyTypeOf() {
+ if (GetClass() == nullptr) {
+ return "(raw)";
+ }
+ std::string temp;
+ std::string result(PrettyDescriptor(GetClass()->GetDescriptor(&temp)));
+ if (IsClass()) {
+ result += "<" + PrettyDescriptor(AsClass()->GetDescriptor(&temp)) + ">";
+ }
+ return result;
+}
+
} // namespace mirror
} // namespace art