Put boot class loader classes and strings in dex cache of app images.
The reason for b/28295348 was that an ArtMethod of the boot image was
in the app image dex cache, but the declaring class of that
boot image method was not.
Since objects of boot images don't need fixups, the comparisons for
FixupStrings and FixupResolvedTypes was always false for them.
bug:28295348
(cherry picked from commit 1df3b55abea375671b79e3f4e6851be757a2d8a7)
Change-Id: I257b68089878ac9ab9f6fc78f726f9fb322dd884
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index c0e5704..9ac27a1 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1666,6 +1666,10 @@
// resolve the same way, simply flatten the hierarchy in the way the resolution order would be,
// and check that the dex file names are the same.
for (mirror::ClassLoader* image_class_loader : image_class_loaders) {
+ if (IsBootClassLoader(soa, image_class_loader)) {
+ // The dex cache can reference types from the boot class loader.
+ continue;
+ }
std::list<mirror::String*> image_dex_file_names;
std::string temp_error_msg;
if (!FlattenPathClassLoader(image_class_loader, &image_dex_file_names, &temp_error_msg)) {
diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h
index 2da3d84..2894b68 100644
--- a/runtime/mirror/dex_cache-inl.h
+++ b/runtime/mirror/dex_cache-inl.h
@@ -148,9 +148,7 @@
for (size_t i = 0, count = NumStrings(); i < count; ++i) {
mirror::String* source = src[i].Read<kReadBarrierOption>();
mirror::String* new_source = visitor(source);
- if (source != new_source) {
- dest[i] = GcRoot<mirror::String>(new_source);
- }
+ dest[i] = GcRoot<mirror::String>(new_source);
}
}
@@ -160,9 +158,7 @@
for (size_t i = 0, count = NumResolvedTypes(); i < count; ++i) {
mirror::Class* source = src[i].Read<kReadBarrierOption>();
mirror::Class* new_source = visitor(source);
- if (source != new_source) {
- dest[i] = GcRoot<mirror::Class>(new_source);
- }
+ dest[i] = GcRoot<mirror::Class>(new_source);
}
}