diff options
| -rw-r--r-- | compiler/verifier_deps_test.cc | 15 | ||||
| -rw-r--r-- | runtime/verifier/verifier_deps.cc | 6 | ||||
| -rw-r--r-- | test/VerifierDeps/MyClassExtendingInterface.smali | 16 |
3 files changed, 33 insertions, 4 deletions
diff --git a/compiler/verifier_deps_test.cc b/compiler/verifier_deps_test.cc index fa7e98586c..3b6b9cc7f0 100644 --- a/compiler/verifier_deps_test.cc +++ b/compiler/verifier_deps_test.cc @@ -207,9 +207,9 @@ class VerifierDepsTest : public CommonCompilerTest { ScopedObjectAccess soa(Thread::Current()); LoadDexFile(&soa); mirror::Class* klass_dst = FindClassByName(dst, &soa); - DCHECK(klass_dst != nullptr); + DCHECK(klass_dst != nullptr) << dst; mirror::Class* klass_src = FindClassByName(src, &soa); - DCHECK(klass_src != nullptr); + DCHECK(klass_src != nullptr) << src; verifier_deps_->AddAssignability(*primary_dex_file_, klass_dst, klass_src, @@ -1536,5 +1536,16 @@ TEST_F(VerifierDepsTest, NotAssignable_InterfaceWithClassInBoot) { ASSERT_TRUE(HasAssignable("Ljava/lang/Exception;", "LIface;", false)); } +TEST_F(VerifierDepsTest, Assignable_Arrays) { + ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "[LIface;", + /* src */ "[LMyClassExtendingInterface;", + /* is_strict */ false, + /* is_assignable */ true)); + ASSERT_FALSE(HasAssignable( + "LIface;", "LMyClassExtendingInterface;", /* expected_is_assignable */ true)); + ASSERT_FALSE(HasAssignable( + "LIface;", "LMyClassExtendingInterface;", /* expected_is_assignable */ false)); +} + } // namespace verifier } // namespace art diff --git a/runtime/verifier/verifier_deps.cc b/runtime/verifier/verifier_deps.cc index 8e4c166492..55e793527e 100644 --- a/runtime/verifier/verifier_deps.cc +++ b/runtime/verifier/verifier_deps.cc @@ -428,8 +428,6 @@ void VerifierDeps::AddAssignability(const DexFile& dex_file, return; } - DCHECK_EQ(is_assignable, destination->IsAssignableFrom(source)); - if (destination->IsArrayClass() && source->IsArrayClass()) { // Both types are arrays. Break down to component types and add recursively. // This helps filter out destinations from compiled DEX files (see below) @@ -447,6 +445,10 @@ void VerifierDeps::AddAssignability(const DexFile& dex_file, is_assignable); return; } + } else { + // We only do this check for non-array types, as arrays might have erroneous + // component types which makes the IsAssignableFrom check unreliable. + DCHECK_EQ(is_assignable, destination->IsAssignableFrom(source)); } DexFileDeps* dex_deps = GetDexFileDeps(dex_file); diff --git a/test/VerifierDeps/MyClassExtendingInterface.smali b/test/VerifierDeps/MyClassExtendingInterface.smali new file mode 100644 index 0000000000..43cf13bb30 --- /dev/null +++ b/test/VerifierDeps/MyClassExtendingInterface.smali @@ -0,0 +1,16 @@ +# 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 LMyClassExtendingInterface; +.super LIface; |