ART: Clean up strings fixup for app images.
This is a follow-up to
https://android-review.googlesource.com/199854 .
Bug: 26846419
Bug: 22858531
Change-Id: Ib2b2c299c51686afb7f297697125296705ed77b8
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index c739490..777786c 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1230,7 +1230,6 @@
DCHECK(strings[j].IsNull());
}
std::copy_n(image_resolved_strings, num_strings, strings);
- *reinterpret_cast<GcRoot<mirror::String>**>(image_resolved_strings) = strings;
dex_cache->SetStrings(strings);
}
if (num_types != 0u) {
@@ -1406,10 +1405,12 @@
if (forward_strings_) {
GcRoot<mirror::String>* strings = klass->GetDexCacheStrings();
if (strings != nullptr) {
- DCHECK(space_->GetImageHeader().GetImageSection(ImageHeader::kSectionDexCacheArrays).Contains(
- reinterpret_cast<uint8_t*>(strings) - space_->Begin()))
+ DCHECK(
+ space_->GetImageHeader().GetImageSection(ImageHeader::kSectionDexCacheArrays).Contains(
+ reinterpret_cast<uint8_t*>(strings) - space_->Begin()))
<< "String dex cache array for " << PrettyClass(klass) << " is not in app image";
- GcRoot<mirror::String>* new_strings = *reinterpret_cast<GcRoot<mirror::String>**>(strings);
+ // Dex caches have already been updated, so take the strings pointer from there.
+ GcRoot<mirror::String>* new_strings = klass->GetDexCache()->GetStrings();
DCHECK_NE(strings, new_strings);
klass->SetDexCacheStrings(new_strings);
}