summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jiakai Zhang <jiakaiz@google.com> 2022-07-04 14:49:08 +0100
committer Jiakai Zhang <jiakaiz@google.com> 2022-07-05 16:30:09 +0100
commit33dce90e7f1d1d15a4af1b8542f192cd28673f0c (patch)
tree22335197ad1b8a9463c747e1ec030d35d22ec910
parent419e5a1277e68813179cf99852e3cf6bc426bcbf (diff)
Update ClassLoaderContext to support artd use cases.
- Change `FlattenDexPaths` to returning `std::vector<std::string>` so that artd can use it in a more flexible way. Bug: 229268202 Test: Presubmit Change-Id: Iab0d018d4f52eea6b60f7f2d88cc56f23db6bd5c Merged-In: Iab0d018d4f52eea6b60f7f2d88cc56f23db6bd5c (cherry picked from commit 55e733f0f582f3edafa2b3bfd1168ade01813a54)
-rw-r--r--dexoptanalyzer/dexoptanalyzer.cc2
-rw-r--r--runtime/class_loader_context.cc9
-rw-r--r--runtime/class_loader_context.h5
3 files changed, 8 insertions, 8 deletions
diff --git a/dexoptanalyzer/dexoptanalyzer.cc b/dexoptanalyzer/dexoptanalyzer.cc
index 7d0aff0cbb..6137766541 100644
--- a/dexoptanalyzer/dexoptanalyzer.cc
+++ b/dexoptanalyzer/dexoptanalyzer.cc
@@ -451,7 +451,7 @@ class DexoptAnalyzer final {
Usage("Invalid --class-loader-context '%s'", context_str_.c_str());
}
- std::cout << context->FlattenDexPaths() << std::flush;
+ std::cout << android::base::Join(context->FlattenDexPaths(), ':') << std::flush;
return ReturnCode::kFlattenClassLoaderContextSuccess;
}
diff --git a/runtime/class_loader_context.cc b/runtime/class_loader_context.cc
index 2419b7b720..31c310e1ec 100644
--- a/runtime/class_loader_context.cc
+++ b/runtime/class_loader_context.cc
@@ -950,12 +950,13 @@ std::vector<const DexFile*> ClassLoaderContext::FlattenOpenedDexFiles() const {
return result;
}
-std::string ClassLoaderContext::FlattenDexPaths() const {
+std::vector<std::string> ClassLoaderContext::FlattenDexPaths() const {
+ std::vector<std::string> result;
+
if (class_loader_chain_ == nullptr) {
- return "";
+ return result;
}
- std::vector<std::string> result;
std::vector<ClassLoaderInfo*> work_list;
work_list.push_back(class_loader_chain_.get());
while (!work_list.empty()) {
@@ -966,7 +967,7 @@ std::string ClassLoaderContext::FlattenDexPaths() const {
}
AddToWorkList(info, work_list);
}
- return FlattenClasspath(result);
+ return result;
}
const char* ClassLoaderContext::GetClassLoaderTypeName(ClassLoaderType type) {
diff --git a/runtime/class_loader_context.h b/runtime/class_loader_context.h
index eceea00177..ccc5c731de 100644
--- a/runtime/class_loader_context.h
+++ b/runtime/class_loader_context.h
@@ -155,9 +155,8 @@ class ClassLoaderContext {
// Should only be called if OpenDexFiles() returned true.
std::vector<const DexFile*> FlattenOpenedDexFiles() const;
- // Return a colon-separated list of dex file locations from this class loader
- // context after flattening.
- std::string FlattenDexPaths() const;
+ // Return a list of dex file locations from this class loader context after flattening.
+ std::vector<std::string> FlattenDexPaths() const;
// Verifies that the current context is identical to the context encoded as `context_spec`.
// Identical means: