Revert "Optimize FindClass ClassNotFoundException case"

Bug: 130310316
Bug: 130293184
Bug: 130209120
Bug: 130680590

Test: TH
This reverts commit 9634705832d5eb1f64af7766917e3043648a538f.

Change-Id: I07f32256fe718c607e9c304073c4f8d614de1c48
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index cdcebf1..3f0713f 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -402,7 +402,7 @@
   }
 }
 
-ClassLinker::ClassLinker(InternTable* intern_table, bool fast_class_not_found_exceptions)
+ClassLinker::ClassLinker(InternTable* intern_table)
     : boot_class_table_(new ClassTable()),
       failed_dex_cache_class_lookups_(0),
       class_roots_(nullptr),
@@ -410,7 +410,6 @@
       init_done_(false),
       log_new_roots_(false),
       intern_table_(intern_table),
-      fast_class_not_found_exceptions_(fast_class_not_found_exceptions),
       quick_resolution_trampoline_(nullptr),
       quick_imt_conflict_trampoline_(nullptr),
       quick_generic_jni_trampoline_(nullptr),
@@ -2948,42 +2947,31 @@
 
       std::string class_name_string(descriptor + 1, descriptor_length - 2);
       std::replace(class_name_string.begin(), class_name_string.end(), '/', '.');
-      if (known_hierarchy &&
-          fast_class_not_found_exceptions_ &&
-          !Runtime::Current()->IsJavaDebuggable()) {
-        // For known hierarchy, we know that the class is going to throw an exception. If we aren't
-        // debuggable, optimize this path by throwing directly here without going back to Java
-        // language. This reduces how many ClassNotFoundExceptions happen.
-        self->ThrowNewExceptionF("Ljava/lang/ClassNotFoundException;",
-                                 "%s",
-                                 class_name_string.c_str());
-      } else {
-        ScopedLocalRef<jobject> class_loader_object(
-            soa.Env(), soa.AddLocalReference<jobject>(class_loader.Get()));
-        ScopedLocalRef<jobject> result(soa.Env(), nullptr);
-        {
-          ScopedThreadStateChange tsc(self, kNative);
-          ScopedLocalRef<jobject> class_name_object(
-              soa.Env(), soa.Env()->NewStringUTF(class_name_string.c_str()));
-          if (class_name_object.get() == nullptr) {
-            DCHECK(self->IsExceptionPending());  // OOME.
-            return nullptr;
-          }
-          CHECK(class_loader_object.get() != nullptr);
-          result.reset(soa.Env()->CallObjectMethod(class_loader_object.get(),
-                                                   WellKnownClasses::java_lang_ClassLoader_loadClass,
-                                                   class_name_object.get()));
-        }
-        if (result.get() == nullptr && !self->IsExceptionPending()) {
-          // broken loader - throw NPE to be compatible with Dalvik
-          ThrowNullPointerException(StringPrintf("ClassLoader.loadClass returned null for %s",
-                                                 class_name_string.c_str()).c_str());
+      ScopedLocalRef<jobject> class_loader_object(
+          soa.Env(), soa.AddLocalReference<jobject>(class_loader.Get()));
+      ScopedLocalRef<jobject> result(soa.Env(), nullptr);
+      {
+        ScopedThreadStateChange tsc(self, kNative);
+        ScopedLocalRef<jobject> class_name_object(
+            soa.Env(), soa.Env()->NewStringUTF(class_name_string.c_str()));
+        if (class_name_object.get() == nullptr) {
+          DCHECK(self->IsExceptionPending());  // OOME.
           return nullptr;
         }
-        result_ptr = soa.Decode<mirror::Class>(result.get());
-        // Check the name of the returned class.
-        descriptor_equals = (result_ptr != nullptr) && result_ptr->DescriptorEquals(descriptor);
+        CHECK(class_loader_object.get() != nullptr);
+        result.reset(soa.Env()->CallObjectMethod(class_loader_object.get(),
+                                                 WellKnownClasses::java_lang_ClassLoader_loadClass,
+                                                 class_name_object.get()));
       }
+      if (result.get() == nullptr && !self->IsExceptionPending()) {
+        // broken loader - throw NPE to be compatible with Dalvik
+        ThrowNullPointerException(StringPrintf("ClassLoader.loadClass returned null for %s",
+                                               class_name_string.c_str()).c_str());
+        return nullptr;
+      }
+      result_ptr = soa.Decode<mirror::Class>(result.get());
+      // Check the name of the returned class.
+      descriptor_equals = (result_ptr != nullptr) && result_ptr->DescriptorEquals(descriptor);
     } else {
       DCHECK(!self->GetException()->InstanceOf(
           GetClassRoot(ClassRoot::kJavaLangClassNotFoundException, this)));