Set dex_cache_strings_ when we call Class::SetDexCache

Ensures that these two variables never get out of sync. The error
was presumably related to not doing this for proxy classes. This
caused java code which was looking at the dex_cache_strings_ field
to incorrectly access a null array.

Bug: 18548887
Change-Id: If53c6ade3588b82a480d6674dfbd5caa2e5069fd
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index c6df340..990a82f 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2715,7 +2715,7 @@
 
   klass->SetDexClassDefIndex(dex_file.GetIndexForClassDef(dex_class_def));
   klass->SetDexTypeIndex(dex_class_def.class_idx_);
-  klass->SetDexCacheStrings(klass->GetDexCache()->GetStrings());
+  CHECK(klass->GetDexCacheStrings() != nullptr);
 
   const byte* class_data = dex_file.GetClassData(dex_class_def);
   if (class_data == nullptr) {
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index 4ef6ea0..b91dfc1 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -149,6 +149,7 @@
 
 void Class::SetDexCache(DexCache* new_dex_cache) {
   SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(Class, dex_cache_), new_dex_cache);
+  SetDexCacheStrings(new_dex_cache != nullptr ? new_dex_cache->GetStrings() : nullptr);
 }
 
 void Class::SetClassSize(uint32_t new_class_size) {
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index 7ef4239..a474166 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -648,6 +648,7 @@
   template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   DexCache* GetDexCache() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
+  // Also updates the dex_cache_strings_ variable from new_dex_cache.
   void SetDexCache(DexCache* new_dex_cache) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
   ALWAYS_INLINE ObjectArray<ArtMethod>* GetDirectMethods()