OSDN Git Service

Fix FindDeclaredVirtualMethod(DexCache...) for miranda methods
authorBrian Carlstrom <bdc@google.com>
Fri, 31 Oct 2014 07:01:54 +0000 (00:01 -0700)
committerBrian Carlstrom <bdc@google.com>
Fri, 31 Oct 2014 07:32:05 +0000 (00:32 -0700)
If a class in classes.dex implements an interface from classes2.dex,
the miranda method will be in the dex cache for classes2.dex, but
pointed to by the virtual methods of the class in the dex caches for
classes.dex.

Therefore the fast path for DexCache::ResolveMethod that searches via
class and superclass virtual methods should ensure that any method
matching on dex method_idx should be from the same dex cache as the
class itself, which is not the case for miranda methods.

Bug: 18193682
Change-Id: I10da4f5472e929b3dc0be58051a726a4bc14e438

runtime/mirror/class.cc

index 5b8eb82..c10e8b1 100644 (file)
@@ -499,7 +499,9 @@ ArtMethod* Class::FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t
   if (GetDexCache() == dex_cache) {
     for (size_t i = 0; i < NumVirtualMethods(); ++i) {
       ArtMethod* method = GetVirtualMethod(i);
-      if (method->GetDexMethodIndex() == dex_method_idx) {
+      if (method->GetDexMethodIndex() == dex_method_idx &&
+          // A miranda method may have a different DexCache.
+          method->GetDexCache() == dex_cache) {
         return method;
       }
     }