From b495e7ffac8782dd2fc7c1a7fa7c69da71d98c1c Mon Sep 17 00:00:00 2001 From: Calin Juravle Date: Mon, 6 Apr 2020 19:29:45 -0700 Subject: Log an error when an app loads duplicate dex files Creating a class loader with duplicate dex files in its classpath is most likely an unintended bug. That leads to rejecting any compiled code and hurts performance by extracting in memory. Test: run-test gtest Bug: 149410951 Change-Id: Ieebb69c6bd03acbe95dd8bedb6101d70390b92d8 --- runtime/class_loader_context.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'runtime/class_loader_context.h') diff --git a/runtime/class_loader_context.h b/runtime/class_loader_context.h index 42ecd3d688..31fd092153 100644 --- a/runtime/class_loader_context.h +++ b/runtime/class_loader_context.h @@ -166,6 +166,11 @@ class ClassLoaderContext { bool verify_names = true, bool verify_checksums = true) const; + // Checks if any of the given dex files is already loaded in the current class loader context. + // Returns the list of duplicate dex files (empty if there are no duplicates). + std::vector CheckForDuplicateDexFiles( + const std::vector& dex_files); + // Creates the class loader context from the given string. // The format: ClassLoaderType1[ClasspathElem1:ClasspathElem2...];ClassLoaderType2[...]... // ClassLoaderType is either "PCL" (PathClassLoader) or "DLC" (DelegateLastClassLoader). -- cgit v1.2.3-59-g8ed1b