Avoid growing boot class path for --single-image compiled images
Calculation of the number of components in Runtime::Init did not
account for images compiled with --single-image where the number of
images does not equal the number of components.
Bug: 160683548
Test: Treehugger
Change-Id: I1db7a4bbbc8bb2f48d54f5048bd1b8407d19cf02
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index f3c58d3..0bed8eb 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1382,6 +1382,11 @@
std::vector<std::unique_ptr<const DexFile>>&& additional_dex_files) {
for (std::unique_ptr<const DexFile>& dex_file : additional_dex_files) {
AppendToBootClassPath(self, dex_file.get());
+ if (kIsDebugBuild) {
+ for (const auto& boot_dex_file : boot_dex_files_) {
+ DCHECK_NE(boot_dex_file->GetLocation(), dex_file->GetLocation());
+ }
+ }
boot_dex_files_.push_back(std::move(dex_file));
}
}