diff options
| -rw-r--r-- | runtime/jdwp/jdwp_handler.cc | 8 | ||||
| -rw-r--r-- | runtime/runtime.cc | 10 |
2 files changed, 14 insertions, 4 deletions
diff --git a/runtime/jdwp/jdwp_handler.cc b/runtime/jdwp/jdwp_handler.cc index b294e480b8..a1d2a6c4bf 100644 --- a/runtime/jdwp/jdwp_handler.cc +++ b/runtime/jdwp/jdwp_handler.cc @@ -333,15 +333,15 @@ static JdwpError VM_ClassPaths(JdwpState*, Request*, ExpandBuf* pReply) std::vector<std::string> class_path; Split(Runtime::Current()->GetClassPathString(), ':', &class_path); expandBufAdd4BE(pReply, class_path.size()); - for (size_t i = 0; i < class_path.size(); ++i) { - expandBufAddUtf8String(pReply, class_path[i]); + for (const std::string& str : class_path) { + expandBufAddUtf8String(pReply, str); } std::vector<std::string> boot_class_path; Split(Runtime::Current()->GetBootClassPathString(), ':', &boot_class_path); expandBufAdd4BE(pReply, boot_class_path.size()); - for (size_t i = 0; i < boot_class_path.size(); ++i) { - expandBufAddUtf8String(pReply, boot_class_path[i]); + for (const std::string& str : boot_class_path) { + expandBufAddUtf8String(pReply, str); } return ERR_NONE; diff --git a/runtime/runtime.cc b/runtime/runtime.cc index fb6034dcd3..c2e814bffe 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -865,6 +865,16 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized) 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); |