Workaround for b/145491866
Check if the type is resolved before invoking CheckInvokeClassMismatch.
Test: test.py
Bug: 145491866
Bug: 73760543
Change-Id: I02714480cef2eece614ef487af60d257f070f46b
diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h
index 69f5a77..c45f001 100644
--- a/runtime/class_linker-inl.h
+++ b/runtime/class_linker-inl.h
@@ -320,6 +320,16 @@
// Check if the invoke type matches the class type.
ObjPtr<mirror::DexCache> dex_cache = referrer->GetDexCache();
ObjPtr<mirror::ClassLoader> class_loader = referrer->GetClassLoader();
+ const dex::MethodId& method_id = referrer->GetDexFile()->GetMethodId(method_idx);
+ ObjPtr<mirror::Class> cls = LookupResolvedType(method_id.class_idx_, dex_cache, class_loader);
+ if (cls == nullptr) {
+ // The verifier breaks the invariant that a resolved method must have its
+ // class in the class table. Because this method should only lookup and not
+ // resolve class, return null. The caller is responsible for calling
+ // `ResolveMethod` afterwards.
+ // b/73760543
+ return nullptr;
+ }
if (CheckInvokeClassMismatch</* kThrow= */ false>(dex_cache, type, method_idx, class_loader)) {
return nullptr;
}