From cb7cfe5dec30e5ec802cfd4eb872f9a7669bac8e Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Fri, 17 Nov 2023 17:02:09 +0000 Subject: Fix the ClassLoaderContext mismatch error message. Before this change, ClassLoaderContext encoding relied on `info.opened_dex_files`. This doesn't work for the error message presentation because we no longer open dex files for ClassLoaderContext verification since https://r.android.com/1531339. This problem leads to empty dex paths in the error message and causes confusion. Note that it does not affect the correctness of ClassLoaderContext verification. This change fixes the presentation problem. Bug: 311126962 Test: m test-art-host-gtest-art_runtime_tests Change-Id: I83972aba7d06a086b7684e2c7ac7640e135e0ee0 --- runtime/class_loader_context.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'runtime/class_loader_context.cc') diff --git a/runtime/class_loader_context.cc b/runtime/class_loader_context.cc index afdbb4a38a..e6cb6d6f8e 100644 --- a/runtime/class_loader_context.cc +++ b/runtime/class_loader_context.cc @@ -696,20 +696,17 @@ void ClassLoaderContext::EncodeContextInternal(const ClassLoaderInfo& info, } } - for (size_t k = 0; k < info.opened_dex_files.size();) { - const std::unique_ptr& dex_file = info.opened_dex_files[k]; - uint32_t checksum = DexFileLoader::GetMultiDexChecksum(info.opened_dex_files, &k); - CHECK(!DexFileLoader::IsMultiDexLocation(dex_file->GetLocation())); - + DCHECK_EQ(info.classpath.size(), info.checksums.size()); + for (size_t i = 0; i < info.classpath.size(); i++) { if (for_dex2oat) { // De-duplicate locations. - bool new_insert = seen_locations.insert(dex_file->GetLocation()).second; + bool new_insert = seen_locations.insert(info.classpath[i]).second; if (!new_insert) { continue; } } - std::string location = dex_file->GetLocation(); + std::string location = info.classpath[i]; // If there is a stored class loader remap, fix up the multidex strings. if (!remap.empty()) { auto it = remap.find(location); @@ -720,7 +717,7 @@ void ClassLoaderContext::EncodeContextInternal(const ClassLoaderInfo& info, // dex2oat does not need the checksums. if (!for_dex2oat) { - checksums.push_back(checksum); + checksums.push_back(info.checksums[i]); } } EncodeClassPath(base_dir, locations, checksums, info.type, out); -- cgit v1.2.3-59-g8ed1b