diff options
-rw-r--r-- | runtime/class_loader_context.cc | 5 | ||||
-rw-r--r-- | runtime/class_loader_context_test.cc | 11 |
2 files changed, 15 insertions, 1 deletions
diff --git a/runtime/class_loader_context.cc b/runtime/class_loader_context.cc index de9fe221ff..0bae60a886 100644 --- a/runtime/class_loader_context.cc +++ b/runtime/class_loader_context.cc @@ -338,6 +338,7 @@ bool ClassLoaderContext::OpenDexFiles(InstructionSet isa, const std::string& cla // no dex files. So that we can distinguish the real failures... const ArtDexFileLoader dex_file_loader; std::vector<ClassLoaderInfo*> work_list; + CHECK(class_loader_chain_ != nullptr); work_list.push_back(class_loader_chain_.get()); while (!work_list.empty()) { ClassLoaderInfo* info = work_list.back(); @@ -908,7 +909,9 @@ ClassLoaderContext::VerificationResult ClassLoaderContext::VerifyClassLoaderCont // collision check. if (expected_context.special_shared_library_) { // Special case where we are the only entry in the class path. - if (class_loader_chain_->parent == nullptr && class_loader_chain_->classpath.size() == 0) { + if (class_loader_chain_ != nullptr && + class_loader_chain_->parent == nullptr && + class_loader_chain_->classpath.size() == 0) { return VerificationResult::kVerifies; } return VerificationResult::kForcedToSkipChecks; diff --git a/runtime/class_loader_context_test.cc b/runtime/class_loader_context_test.cc index cb3dc6506f..f3e2ac00ba 100644 --- a/runtime/class_loader_context_test.cc +++ b/runtime/class_loader_context_test.cc @@ -735,6 +735,17 @@ TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatch) { ClassLoaderContext::VerificationResult::kMismatch); } +TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatchSpecial) { + std::string context_spec = "&"; + std::unique_ptr<ClassLoaderContext> context = ParseContextWithChecksums(context_spec); + // Pretend that we successfully open the dex files to pass the DCHECKS. + // (as it's much easier to test all the corner cases without relying on actual dex files). + PretendContextOpenedDexFiles(context.get()); + + ASSERT_EQ(context->VerifyClassLoaderContextMatch(context_spec), + ClassLoaderContext::VerificationResult::kForcedToSkipChecks); +} + TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatchWithSL) { std::string context_spec = "PCL[a.dex*123:b.dex*456]{PCL[d.dex*321];PCL[e.dex*654]#PCL[f.dex*098:g.dex*999]}" |