Handle the situation we could not load the class.

This happens with the JIT thread through custom class loaders.

Test: test.py
Bug: 73760543
Change-Id: Ic27a9f8ddd02ba1408963d3cb00ef1ef4da3c063
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 8f8f4fd..6573bc0 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -8779,8 +8779,13 @@
       // We normaly should not end up here. However the verifier currently doesn't guarantee
       // the invariant of having the klass in the class table. b/73760543
       klass = ResolveType(method_id.class_idx_, dex_cache, class_loader);
-      DCHECK(!Thread::Current()->IsExceptionPending())
-          << Thread::Current()->GetException()->Dump();
+      if (klass == nullptr) {
+        // This can only happen if the current thread is not allowed to load
+        // classes.
+        DCHECK(!Thread::Current()->CanLoadClasses());
+        DCHECK(Thread::Current()->IsExceptionPending());
+        return nullptr;
+      }
     }
   } else {
     // The method was not in the DexCache, resolve the declaring class.