Test and fixes for invoke-interface on java.lang.Object methods.
Bug: 7614818
Change-Id: I704596cf3d36887e6d6d589cb3ec89e31d5b8901
diff --git a/src/class_linker.cc b/src/class_linker.cc
index ca8a532..6fc6a3d 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -3603,11 +3603,11 @@
}
AbstractMethod* ClassLinker::ResolveMethod(const DexFile& dex_file,
- uint32_t method_idx,
- DexCache* dex_cache,
- ClassLoader* class_loader,
- const AbstractMethod* referrer,
- InvokeType type) {
+ uint32_t method_idx,
+ DexCache* dex_cache,
+ ClassLoader* class_loader,
+ const AbstractMethod* referrer,
+ InvokeType type) {
DCHECK(dex_cache != NULL);
// Check for hit in the dex cache.
AbstractMethod* resolved = dex_cache->GetResolvedMethod(method_idx);
@@ -3630,6 +3630,7 @@
break;
case kInterface:
resolved = klass->FindInterfaceMethod(dex_cache, method_idx);
+ DCHECK(resolved == NULL || resolved->GetDeclaringClass()->IsInterface());
break;
case kSuper: // Fall-through.
case kVirtual:
@@ -3649,6 +3650,7 @@
break;
case kInterface:
resolved = klass->FindInterfaceMethod(name, signature);
+ DCHECK(resolved == NULL || resolved->GetDeclaringClass()->IsInterface());
break;
case kSuper: // Fall-through.
case kVirtual:
diff --git a/src/object.cc b/src/object.cc
index df42f8c..8565c38 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -1098,7 +1098,7 @@
return NULL;
}
-AbstractMethod* Class::FindInterfaceMethod(const StringPiece& name, const StringPiece& signature) const {
+AbstractMethod* Class::FindInterfaceMethod(const StringPiece& name, const StringPiece& signature) const {
// Check the current class before checking the interfaces.
AbstractMethod* method = FindDeclaredVirtualMethod(name, signature);
if (method != NULL) {
@@ -1108,7 +1108,7 @@
int32_t iftable_count = GetIfTableCount();
IfTable* iftable = GetIfTable();
for (int32_t i = 0; i < iftable_count; i++) {
- method = iftable->GetInterface(i)->FindVirtualMethod(name, signature);
+ method = iftable->GetInterface(i)->FindDeclaredVirtualMethod(name, signature);
if (method != NULL) {
return method;
}
@@ -1126,7 +1126,7 @@
int32_t iftable_count = GetIfTableCount();
IfTable* iftable = GetIfTable();
for (int32_t i = 0; i < iftable_count; i++) {
- method = iftable->GetInterface(i)->FindVirtualMethod(dex_cache, dex_method_idx);
+ method = iftable->GetInterface(i)->FindDeclaredVirtualMethod(dex_cache, dex_method_idx);
if (method != NULL) {
return method;
}
diff --git a/src/object.h b/src/object.h
index ecd086b..0eea8c3 100644
--- a/src/object.h
+++ b/src/object.h
@@ -986,7 +986,7 @@
ObjectArray<StaticStorageBase>* dex_cache_initialized_static_storage_;
// short cuts to declaring_class_->dex_cache_ member for fast compiled code access
- ObjectArray<Class>* dex_cache_resolved_methods_;
+ ObjectArray<AbstractMethod>* dex_cache_resolved_methods_;
// short cuts to declaring_class_->dex_cache_ member for fast compiled code access
ObjectArray<Class>* dex_cache_resolved_types_;