diff options
author | 2023-02-13 12:42:12 +0000 | |
---|---|---|
committer | 2023-02-21 18:00:00 +0000 | |
commit | 052f5fb6d28717b7ff236c508f5fb36a7705f662 (patch) | |
tree | d148b944857d92cc4ad5666f7139c16b6ba56394 /runtime/class_loader_context.cc | |
parent | 4184f23701a64e9902ffced803968fcc5601764b (diff) |
Refactor DexFileLoader
The first parameter of the Open methods specifies the data source,
that we intend to load the dex file(s) from. This creates large number
of overloads when multiplied by diversity of the other arguments.
Move the data source parameters to the constructor of DexFileLoader.
Specifically, the constructor just creates the right DexFileContainer,
and the rest of the loader is independent of the data source used.
This removes large amount of the overloads as well as large amount
of copy-pasted code. Majority of ArtDexFileLoader has been removed.
Bug: 266950186
Test: ./art/test.py -b --host --optimizing --64
Change-Id: I6580b49e65441eec93a7e0124be23bd8c859904a
Diffstat (limited to 'runtime/class_loader_context.cc')
-rw-r--r-- | runtime/class_loader_context.cc | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/runtime/class_loader_context.cc b/runtime/class_loader_context.cc index 722b8f7a64..074a819d0a 100644 --- a/runtime/class_loader_context.cc +++ b/runtime/class_loader_context.cc @@ -438,7 +438,6 @@ bool ClassLoaderContext::OpenDexFiles(const std::string& classpath_dir, // We may get resource-only apks which we cannot load. // TODO(calin): Refine the dex opening interface to be able to tell if an archive contains // no dex files. So that we can distinguish the real failures... - const ArtDexFileLoader dex_file_loader; std::vector<ClassLoaderInfo*> work_list; if (class_loader_chain_ == nullptr) { return true; @@ -480,12 +479,12 @@ bool ClassLoaderContext::OpenDexFiles(const std::string& classpath_dir, std::string error_msg; if (only_read_checksums) { bool zip_file_only_contains_uncompress_dex; - if (!dex_file_loader.GetMultiDexChecksums(location.c_str(), - &dex_checksums, - &dex_locations, - &error_msg, - fd, - &zip_file_only_contains_uncompress_dex)) { + if (!ArtDexFileLoader::GetMultiDexChecksums(location.c_str(), + &dex_checksums, + &dex_locations, + &error_msg, + fd, + &zip_file_only_contains_uncompress_dex)) { LOG(WARNING) << "Could not get dex checksums for location " << location << ", fd=" << fd; dex_files_state_ = kDexFilesOpenFailed; } @@ -495,11 +494,9 @@ bool ClassLoaderContext::OpenDexFiles(const std::string& classpath_dir, // We don't need to do structural dex file verification, we only need to // check the checksum, so pass false to verify. size_t opened_dex_files_index = info->opened_dex_files.size(); - if (!dex_file_loader.Open(location.c_str(), - fd, - location.c_str(), - /*verify=*/ false, - /*verify_checksum=*/ true, + ArtDexFileLoader dex_file_loader(location.c_str(), fd, location); + if (!dex_file_loader.Open(/*verify=*/false, + /*verify_checksum=*/true, &error_msg, &info->opened_dex_files)) { LOG(WARNING) << "Could not open dex files for location " << location << ", fd=" << fd; |