diff options
| author | 2017-01-05 15:23:19 +0000 | |
|---|---|---|
| committer | 2017-01-05 15:23:19 +0000 | |
| commit | 0f1cb17d23b664b96b6966e5d0f280df5925f56f (patch) | |
| tree | 2f93076ee34cd1754806a653a1119a5ec81e2c9e | |
| parent | 77e9bddee965b1cefdc77264e4ed3a19e90cc2ac (diff) | |
Actually record arrays in classpath.
With https://android-review.googlesource.com/#/c/316151/,
I was under the wrong impression arrays all have the same
access flags. They actually have the visibility of the inner
most component type.
Therefore, we still need to record visibility of array types whose
innermost component type is in the classpath.
Test: verifier_deps_test
Change-Id: If7b1004efb679e320330258f42ced83b8eedae87
| -rw-r--r-- | compiler/verifier_deps_test.cc | 10 | ||||
| -rw-r--r-- | runtime/verifier/verifier_deps.cc | 20 |
2 files changed, 20 insertions, 10 deletions
diff --git a/compiler/verifier_deps_test.cc b/compiler/verifier_deps_test.cc index 85ae61f1bd..e716cdbed8 100644 --- a/compiler/verifier_deps_test.cc +++ b/compiler/verifier_deps_test.cc @@ -1101,6 +1101,16 @@ TEST_F(VerifierDepsTest, InvokeSuper_ThisNotAssignable) { "virtual", "Ljava/lang/Integer;", "intValue", "()I", true, "public", "Ljava/lang/Integer;")); } +TEST_F(VerifierDepsTest, ArgumentType_ResolvedReferenceArray) { + ASSERT_TRUE(VerifyMethod("ArgumentType_ResolvedReferenceArray")); + ASSERT_TRUE(HasClass("[Ljava/lang/Thread;", true, "public final abstract")); +} + +TEST_F(VerifierDepsTest, NewArray_Resolved) { + ASSERT_TRUE(VerifyMethod("NewArray_Resolved")); + ASSERT_TRUE(HasClass("[Ljava/lang/IllegalStateException;", true, "public final abstract")); +} + TEST_F(VerifierDepsTest, EncodeDecode) { VerifyDexFile(); diff --git a/runtime/verifier/verifier_deps.cc b/runtime/verifier/verifier_deps.cc index 5f94a1bd9b..c4058d63ee 100644 --- a/runtime/verifier/verifier_deps.cc +++ b/runtime/verifier/verifier_deps.cc @@ -245,18 +245,18 @@ std::string VerifierDeps::GetStringFromId(const DexFile& dex_file, dex::StringIn bool VerifierDeps::IsInClassPath(ObjPtr<mirror::Class> klass) const { DCHECK(klass != nullptr); - ObjPtr<mirror::DexCache> dex_cache = klass->GetDexCache(); - if (dex_cache == nullptr) { - // This is a synthesized class, in this case always an array. They are not - // defined in the compiled DEX files and therefore are part of the classpath. - // We do not record dependencies on arrays with component types in - // the compiled DEX files, as the only thing that might change is their - // access flags. If we were to change these flags in a breaking way, we would - // need to enforce full verification again anyways by updating the vdex version. - DCHECK(klass->IsArrayClass()) << klass->PrettyDescriptor(); - return false; + // For array types, we return whether the non-array component type + // is in the classpath. + while (klass->IsArrayClass()) { + klass = klass->GetComponentType(); } + if (klass->IsPrimitive()) { + return true; + } + + ObjPtr<mirror::DexCache> dex_cache = klass->GetDexCache(); + DCHECK(dex_cache != nullptr); const DexFile* dex_file = dex_cache->GetDexFile(); DCHECK(dex_file != nullptr); |