Search only the current class loader when checking for duplicates
Do not check the entire class loader hierarchy for duplicate dex files
because some use cases might be valid. The most error prone cases are
actually duplicates within the same class loader.
Test: gtest
Bug: 154032843
Change-Id: I8c5efd4b2053a5b4052de6041d561554dddf4780
Merged-In: I8c5efd4b2053a5b4052de6041d561554dddf4780
(cherry picked from commit 86ac525b1f42876518c9040aeaf1a9710cc4332e)
diff --git a/runtime/class_loader_context.h b/runtime/class_loader_context.h
index 31fd092..d564ec8 100644
--- a/runtime/class_loader_context.h
+++ b/runtime/class_loader_context.h
@@ -19,6 +19,7 @@
#include <string>
#include <vector>
+#include <set>
#include "arch/instruction_set.h"
#include "base/dchecked_vector.h"
@@ -167,8 +168,9 @@
bool verify_checksums = true) const;
// Checks if any of the given dex files is already loaded in the current class loader context.
+ // It only checks the first class loader.
// Returns the list of duplicate dex files (empty if there are no duplicates).
- std::vector<const DexFile*> CheckForDuplicateDexFiles(
+ std::set<const DexFile*> CheckForDuplicateDexFiles(
const std::vector<const DexFile*>& dex_files);
// Creates the class loader context from the given string.