AOT verification not founds are generic failures until runtime

Make compile time verification failure of class, field and method not
found generic failures so that we reverify at runtime with complete
class loader accessibility.

Change-Id: Iad2a1d3b37d9b5baba6b8bc9a4549ffd70b9a2bc
diff --git a/src/dex_verifier.cc b/src/dex_verifier.cc
index 16506ca..adf0288 100644
--- a/src/dex_verifier.cc
+++ b/src/dex_verifier.cc
@@ -1030,6 +1030,26 @@
   return result;
 }
 
+std::ostream& DexVerifier::Fail(VerifyError error) {
+  CHECK_EQ(failure_, VERIFY_ERROR_NONE);
+  // If we're optimistically running verification at compile time, turn NO_xxx errors into generic
+  // errors so that we reverify at runtime
+  if (Runtime::Current()->IsCompiler()) {
+    switch(error) {
+      case VERIFY_ERROR_NO_CLASS:
+      case VERIFY_ERROR_NO_FIELD:
+      case VERIFY_ERROR_NO_METHOD:
+        error = VERIFY_ERROR_GENERIC;
+        break;
+      default:
+        break;
+    }
+  }
+  failure_ = error;
+  return fail_messages_ << "VFY: " << PrettyMethod(method_)
+                        << '[' << reinterpret_cast<void*>(work_insn_idx_) << "] : ";
+}
+
 bool DexVerifier::ComputeWidthsAndCountOps() {
   const uint16_t* insns = code_item_->insns_;
   size_t insns_size = code_item_->insns_size_in_code_units_;
diff --git a/src/dex_verifier.h b/src/dex_verifier.h
index 2d06432..cbf26d6 100644
--- a/src/dex_verifier.h
+++ b/src/dex_verifier.h
@@ -903,12 +903,7 @@
   }
 
   // Verification failed
-  std::ostream& Fail(VerifyError error) {
-    CHECK_EQ(failure_, VERIFY_ERROR_NONE);
-    failure_ = error;
-    return fail_messages_ << "VFY: " << PrettyMethod(method_)
-                          << '[' << reinterpret_cast<void*>(work_insn_idx_) << "] : ";
-  }
+  std::ostream& Fail(VerifyError error);
 
   // Log for verification information
   std::ostream& LogVerifyInfo() {