Fix calling instance methods of erroneous classes.

Fix the resolution trampoline to correctly handle the edge
case of calling instance methods on instances of erroneous
classes. The new test case would have previously failed the
`CHECK_EQ(code == nullptr, self->IsExceptionPending())`
because the trampoline would not retrieve the code pointer
for the direct method of an erroneous class.

Test: Added test to 174-escaping-instance-of-bad-class.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: aosp_taimen-userdebug boots.
Bug: 62478025
Change-Id: Idf54a010f362c6f581a4c4aa27c33b6dc3ce6f69
diff --git a/test/174-escaping-instance-of-bad-class/src/Main.java b/test/174-escaping-instance-of-bad-class/src/Main.java
index 4f66a31..cee978a 100644
--- a/test/174-escaping-instance-of-bad-class/src/Main.java
+++ b/test/174-escaping-instance-of-bad-class/src/Main.java
@@ -50,6 +50,9 @@
         ncdfe.printStackTrace();
       }
     }
+
+    // Test that we handle bad instance correctly in the resolution trampoline.
+    bad.$noinline$testResolutionTrampoline();
   }
 
   public static void hierarchyTest() {
@@ -141,6 +144,15 @@
       return Bad.staticValue;
     }
   }
+
+  public void $noinline$testResolutionTrampoline() {
+    // The first call to private method uses the resolution trampoline when AOT-compiled.
+    $noinline$testResolutionTrampolineCallee();
+  }
+
+  private void $noinline$testResolutionTrampolineCallee() {
+    System.out.println("Bad.$noinline$testResolutionTrampolineCallee()");
+  }
 }
 
 class BadSuper {