Prune class path classes from profile
Fixes a theoretical case where classes not in the app, but in the in
the class path could have been included in the image. The dex caches
for these classes are not properly handled and need to be pruned.
Not including the classes in the image classes makes sure the that
class linker automatically prunes them and frees the dex cache with
the explicit garbage collection.
Bug: 28452385
(cherry picked from commit 8d26c5967674d2eab21f65eeac9f1adcf88fce38)
Change-Id: Ic33076f0a76cf1ae727c61a340ceaadf9e7e7d08
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index be720ad..eaeacc5 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -437,6 +437,9 @@
continue;
}
const DexFile* dex_file = dex_cache->GetDexFile();
+ CHECK(dex_file_oat_index_map_.find(dex_file) != dex_file_oat_index_map_.end())
+ << "Dex cache should have been pruned " << dex_file->GetLocation()
+ << "; possibly in class path";
DexCacheArraysLayout layout(target_ptr_size_, dex_file);
DCHECK(layout.Valid());
size_t oat_index = GetOatIndexForDexCache(dex_cache);