Revert^2 "Throw ClassFormatError for unsupported default methods."

This reverts commit 09261a8c5cd36a8c7a1ae5107da554dd35008b97.

Fixed redefine-stress failures. Worked around CTS failures
by reducing the cases where we throw the ClassFormatError.

Test: 180-native-default-method.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: aosp_taimen-userdebug boots.
Test: testrunner.py --host --optimizing --redefine-stress \
      --debug --debugggable --cdex-fast
Test: cts-tradefed run cts --m vm-tests-tf
Bug: 157170505
Bug: 157718952
Change-Id: I95264af9041836fd6bc54e85263e2a405e877d30
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index c8d4d63..4b8a94f 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -6432,6 +6432,19 @@
       ArtMethod* m = klass->GetVirtualMethodDuringLinking(i, image_pointer_size_);
       m->SetMethodIndex(i);
       if (!m->IsAbstract()) {
+        // If the dex file does not support default methods, throw ClassFormatError.
+        // This check is necessary to protect from odd cases, such as native default
+        // methods, that the dex file verifier permits for old dex file versions. b/157170505
+        // FIXME: This should be `if (!m->GetDexFile()->SupportsDefaultMethods())` but we're
+        // currently running CTS tests for default methods with dex file version 035 which
+        // does not support default methods. So, we limit this to native methods. b/157718952
+        if (m->IsNative()) {
+          DCHECK(!m->GetDexFile()->SupportsDefaultMethods());
+          ThrowClassFormatError(klass.Get(),
+                                "Dex file does not support default method '%s'",
+                                m->PrettyMethod().c_str());
+          return false;
+        }
         m->SetAccessFlags(m->GetAccessFlags() | kAccDefault);
         has_defaults = true;
       }