Fix debugger crashes in presence of proxy objects.
Fix ClassHelper::NumDirectInterfaces to use IfTable::Count instead of the
iftable array's length (which is twice the interface count). This happens when
processing ReferenceType::Interfaces command and was causing a crash.
Return ABSENT_INFORMATION error code when we're asked for the source file of a
proxy class. Otherwise we call ClassHelper::GetSourceFile which expect the
class has a corresponding ClassDef item in the DEX file which is not true for
proxy classes.
Add new proxy_test to check ClassHelper works correctly with proxy classes.
Bug: 13426918
Change-Id: I5c1212b1a697dd7dc1ab18e99552ee113c533a5a
diff --git a/runtime/object_utils.h b/runtime/object_utils.h
index dd2bd4f..9ddeeca 100644
--- a/runtime/object_utils.h
+++ b/runtime/object_utils.h
@@ -133,7 +133,7 @@
} else if (klass_->IsArrayClass()) {
return 2;
} else if (klass_->IsProxyClass()) {
- return klass_->GetIfTable()->GetLength();
+ return klass_->GetIfTable()->Count();
} else {
const DexFile::TypeList* interfaces = GetInterfaceTypeList();
if (interfaces == nullptr) {
@@ -180,7 +180,7 @@
std::string descriptor(GetDescriptor());
const DexFile& dex_file = GetDexFile();
const DexFile::ClassDef* dex_class_def = GetClassDef();
- CHECK(dex_class_def != nullptr);
+ CHECK(dex_class_def != nullptr) << "No class def for class " << PrettyClass(klass_);
return dex_file.GetSourceFile(*dex_class_def);
}