Revert "Revert "Refactor annotation code for obsolete methods.""

The number of InterruptedExceptions created during runtime shutdown is
sometimes inconsistent so we will filter those out of the test results.

This reverts commit 65e0775010121498a37fa26c64fcc5bb17a6c1b5.

Reason for revert: Fixed issue with test flakes

Bug: 31455788
Test: stress --cpu 60; while ./test/run-test --host 980; do; done

Change-Id: Idf53ea11ceec1f48c433da468b31092bf230de57
diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h
index 685e26c..b47f8f0 100644
--- a/runtime/art_method-inl.h
+++ b/runtime/art_method-inl.h
@@ -347,7 +347,11 @@
 
 inline uint16_t ArtMethod::GetClassDefIndex() {
   DCHECK(!IsProxyMethod());
-  return GetDeclaringClass()->GetDexClassDefIndex();
+  if (LIKELY(!IsObsolete())) {
+    return GetDeclaringClass()->GetDexClassDefIndex();
+  } else {
+    return FindObsoleteDexClassDefIndex();
+  }
 }
 
 inline const DexFile::ClassDef& ArtMethod::GetClassDef() {