Remove abuse of mirror::Object* to reference special values.
Remove kInvalidIndirectRefObject, kClearedJniWeakGlobal and
ObjectRegistry::kInvalidObject. Handle error conditions by passing in or
returning an error value.
GetObjectRefType is simplified to be faster and not return invalid references
that are not expected according to the spec. Adjust check JNI and
jni_internal_test appropriately.
Fix cases in the debugger/JDWP of out arguments being passed by reference.
Bug: 17376993
Change-Id: I3ce8a28c01827e163f4dc288449959464da788b1
diff --git a/runtime/jdwp/object_registry.cc b/runtime/jdwp/object_registry.cc
index ad18d8a..35aaf0a 100644
--- a/runtime/jdwp/object_registry.cc
+++ b/runtime/jdwp/object_registry.cc
@@ -21,8 +21,6 @@
namespace art {
-mirror::Object* const ObjectRegistry::kInvalidObject = reinterpret_cast<mirror::Object*>(1);
-
std::ostream& operator<<(std::ostream& os, const ObjectRegistryEntry& rhs) {
os << "ObjectRegistryEntry[" << rhs.jni_reference_type
<< ",reference=" << rhs.jni_reference
@@ -129,14 +127,16 @@
id_to_entry_.clear();
}
-mirror::Object* ObjectRegistry::InternalGet(JDWP::ObjectId id) {
+mirror::Object* ObjectRegistry::InternalGet(JDWP::ObjectId id, JDWP::JdwpError* error) {
Thread* self = Thread::Current();
MutexLock mu(self, lock_);
auto it = id_to_entry_.find(id);
if (it == id_to_entry_.end()) {
- return kInvalidObject;
+ *error = JDWP::ERR_INVALID_OBJECT;
+ return nullptr;
}
ObjectRegistryEntry& entry = *it->second;
+ *error = JDWP::ERR_NONE;
return self->DecodeJObject(entry.jni_reference);
}