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

(cherry picked from commit ea1c3d77b92b30ec527f2ca5bfe316a882b698e0)

Change-Id: I022d9311b38b61e160ed70e3c5d9639797adb29c
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index f092772..4bd702d 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2780,7 +2780,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 uint8_t* 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 5665059..bd3bfbf 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 56867dd..812cfd3 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -658,6 +658,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()