diff options
| author | 2017-03-16 16:51:59 +0000 | |
|---|---|---|
| committer | 2017-03-17 08:59:25 +0000 | |
| commit | fc38e919bad23670e38a484d4728f300406415c3 (patch) | |
| tree | ec249a6773e571244d30c980263e32c750fb4c96 | |
| parent | f83f3f6ecb1153d96cc8007e8a0d1e35af4d3f38 (diff) | |
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
| -rw-r--r-- | compiler/verifier_deps_test.cc | 8 | ||||
| -rw-r--r-- | runtime/verifier/verifier_deps.cc | 3 | ||||
| -rw-r--r-- | test/VerifierDeps/Iface.smali | 18 |
3 files changed, 27 insertions, 2 deletions
diff --git a/compiler/verifier_deps_test.cc b/compiler/verifier_deps_test.cc index 1a1d163304..4bfc84990d 100644 --- a/compiler/verifier_deps_test.cc +++ b/compiler/verifier_deps_test.cc @@ -1528,5 +1528,13 @@ TEST_F(VerifierDepsTest, MultiDexVerification) { 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 d477ecdb7c..8e4c166492 100644 --- a/runtime/verifier/verifier_deps.cc +++ b/runtime/verifier/verifier_deps.cc @@ -462,8 +462,7 @@ void VerifierDeps::AddAssignability(const DexFile& dex_file, } 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 0000000000..8607307093 --- /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; |