Do not assume type relationship when recording "not assignable"
The verifier may record that an interface I does not extend a
class A. If A is not j.l.Object, this is always true, but
A might change after a system update from a class to an interface.
bug: 34849974
test: verifier_deps_test
Change-Id: Ic2876edce9a2a6f7b402420a5e01763aba2b39a4
diff --git a/compiler/verifier_deps_test.cc b/compiler/verifier_deps_test.cc
index 1a1d163..4bfc849 100644
--- a/compiler/verifier_deps_test.cc
+++ b/compiler/verifier_deps_test.cc
@@ -1528,5 +1528,13 @@
ASSERT_FALSE(buffer.empty());
}
+TEST_F(VerifierDepsTest, NotAssignable_InterfaceWithClassInBoot) {
+ ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "Ljava/lang/Exception;",
+ /* src */ "LIface;",
+ /* is_strict */ true,
+ /* is_assignable */ false));
+ ASSERT_TRUE(HasAssignable("Ljava/lang/Exception;", "LIface;", false));
+}
+
} // namespace verifier
} // namespace art
diff --git a/runtime/verifier/verifier_deps.cc b/runtime/verifier/verifier_deps.cc
index d477ecd..8e4c166 100644
--- a/runtime/verifier/verifier_deps.cc
+++ b/runtime/verifier/verifier_deps.cc
@@ -462,8 +462,7 @@
}
if (!IsInClassPath(source)) {
- if (!destination->IsInterface()) {
- DCHECK(!source->IsInterface());
+ if (!destination->IsInterface() && !source->IsInterface()) {
// Find the super class at the classpath boundary. Only that class
// can change the assignability.
do {
diff --git a/test/VerifierDeps/Iface.smali b/test/VerifierDeps/Iface.smali
new file mode 100644
index 0000000..8607307
--- /dev/null
+++ b/test/VerifierDeps/Iface.smali
@@ -0,0 +1,18 @@
+# /*
+# * Copyright (C) 2017 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 abstract interface LIface;
+.super Ljava/lang/Object;