Revert "Throw ClassFormatError for unsupported default methods."
This reverts commit adf0f2e55c285f3fbe0a70c218a8f267029e736c.
Bug: 157170505
Bug: 157575227
Reason for revert: b/157575227
Change-Id: Ibc0aa5505a59deed717555441a9723b5b6561115
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index bbf59bc..c8d4d63 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -6432,15 +6432,6 @@
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
- if (!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;
}
diff --git a/test/180-native-default-method/build b/test/180-native-default-method/build
deleted file mode 100644
index 3963fd3..0000000
--- a/test/180-native-default-method/build
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2020 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# make us exit on a failure
-set -e
-
-./default-build "$@"
-
-if [[ $@ != *"--jvm"* ]]; then
- # Change the generated dex file to have a v35 magic number if it is version 39
- if test -f classes.dex && head -c 7 classes.dex | grep -q 039; then
- # place ascii value '035' into the classes.dex file starting at byte 4.
- printf '035' | dd status=none conv=notrunc of=classes.dex bs=1 seek=4 count=3
- rm -f $TEST_NAME.jar
- zip $TEST_NAME.jar classes.dex
- fi
-fi
diff --git a/test/180-native-default-method/expected.txt b/test/180-native-default-method/expected.txt
deleted file mode 100644
index b0aad4d..0000000
--- a/test/180-native-default-method/expected.txt
+++ /dev/null
@@ -1 +0,0 @@
-passed
diff --git a/test/180-native-default-method/info.txt b/test/180-native-default-method/info.txt
deleted file mode 100644
index 0cba4eb..0000000
--- a/test/180-native-default-method/info.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Regression test for DCHECK() failure for copying a default native method from
-an interface to a class implementing that interface. The default native method
-should result in ClassFormatError before we reach that DCHECK().
diff --git a/test/180-native-default-method/jasmin/TestClass.j b/test/180-native-default-method/jasmin/TestClass.j
deleted file mode 100644
index fddd99b..0000000
--- a/test/180-native-default-method/jasmin/TestClass.j
+++ /dev/null
@@ -1,25 +0,0 @@
-; Copyright (C) 2020 The Android Open Source Project
-;
-; Licensed under the Apache License, Version 2.0 (the "License");
-; you may not use this file except in compliance with the License.
-; You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-
-.class public TestClass
-.super java/lang/Object
-.implements TestInterface
-
-.method public <init>()V
- .limit stack 1
- .limit locals 1
- aload_0
- invokespecial java/lang/Object/<init>()V
- return
-.end method
diff --git a/test/180-native-default-method/jasmin/TestInterface.j b/test/180-native-default-method/jasmin/TestInterface.j
deleted file mode 100644
index 080474e..0000000
--- a/test/180-native-default-method/jasmin/TestInterface.j
+++ /dev/null
@@ -1,19 +0,0 @@
-; Copyright (C) 2020 The Android Open Source Project
-;
-; Licensed under the Apache License, Version 2.0 (the "License");
-; you may not use this file except in compliance with the License.
-; You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-
-.interface public TestInterface
-.super java/lang/Object
-
-.method public native foo()V
-.end method
diff --git a/test/180-native-default-method/src/Main.java b/test/180-native-default-method/src/Main.java
deleted file mode 100644
index 4b2704b..0000000
--- a/test/180-native-default-method/src/Main.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class Main {
- public static void main(String args[]) {
- try {
- // Regression test for default native methods that should cause ClassFormatException
- // if they pass the dex file verification, i.e. for old dex file versions.
- // We previously did not handle this case properly and failed a DCHECK() for
- // a non-interface class creating a copied method that was native. b/157170505
- Class.forName("TestClass");
- throw new Error("UNREACHABLE");
- } catch (ClassFormatError expected) {
- System.out.println("passed");
- } catch (Throwable unexpected) {
- unexpected.printStackTrace();
- }
- }
-}