Fix bootclasspath string initialization
When running the runtime with an image without explicitly specifying
the bootclasspath (with the -Xbootclasspath option), we construct it
from the location of DEX files loaded from the image.
This allows to fix the JDWP test ClassPathsTest#testClassPaths001 on
the host where the bootclasspath is not explicitly specified on the
command line.
Bug: 18812378
Change-Id: I726eafd8b9e59dc9513beeb7082cf086fe89c4b1
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index fb6034d..c2e814b 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -865,6 +865,16 @@
if (kIsDebugBuild) {
GetHeap()->GetImageSpace()->VerifyImageAllocations();
}
+ if (boot_class_path_string_.empty()) {
+ // The bootclasspath is not explicitly specified: construct it from the loaded dex files.
+ const std::vector<const DexFile*>& boot_class_path = GetClassLinker()->GetBootClassPath();
+ std::vector<std::string> dex_locations;
+ dex_locations.reserve(boot_class_path.size());
+ for (const DexFile* dex_file : boot_class_path) {
+ dex_locations.push_back(dex_file->GetLocation());
+ }
+ boot_class_path_string_ = Join(dex_locations, ':');
+ }
} else {
std::vector<std::string> dex_filenames;
Split(boot_class_path_string_, ':', &dex_filenames);