Make DexCache references const.

Clean up after https://android-review.googlesource.com/80446 .

Change-Id: I32dac9d8aa68bb891ec8b551d771f65db7be409d
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 8aa8333..8ddaeb2 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -205,13 +205,13 @@
 
 template <bool throw_on_failure, bool use_referrers_cache>
 inline bool Class::ResolvedFieldAccessTest(Class* access_to, ArtField* field,
-                                           uint32_t field_idx, DexCache* dex_cache) {
+                                           uint32_t field_idx, const DexCache* dex_cache) {
   DCHECK_EQ(use_referrers_cache, dex_cache == nullptr);
   if (UNLIKELY(!this->CanAccess(access_to))) {
     // The referrer class can't access the field's declaring class but may still be able
     // to access the field if the FieldId specifies an accessible subclass of the declaring
     // class rather than the declaring class itself.
-    DexCache* referrer_dex_cache = use_referrers_cache ? this->GetDexCache() : dex_cache;
+    const DexCache* referrer_dex_cache = use_referrers_cache ? this->GetDexCache() : dex_cache;
     uint32_t class_idx = referrer_dex_cache->GetDexFile()->GetFieldId(field_idx).class_idx_;
     // The referenced class has already been resolved with the field, get it from the dex cache.
     Class* dex_access_to = referrer_dex_cache->GetResolvedType(class_idx);
@@ -236,14 +236,14 @@
 
 template <bool throw_on_failure, bool use_referrers_cache, InvokeType throw_invoke_type>
 inline bool Class::ResolvedMethodAccessTest(Class* access_to, ArtMethod* method,
-                                            uint32_t method_idx, DexCache* dex_cache) {
+                                            uint32_t method_idx, const DexCache* dex_cache) {
   COMPILE_ASSERT(throw_on_failure || throw_invoke_type == kStatic, non_default_throw_invoke_type);
   DCHECK_EQ(use_referrers_cache, dex_cache == nullptr);
   if (UNLIKELY(!this->CanAccess(access_to))) {
     // The referrer class can't access the method's declaring class but may still be able
     // to access the method if the MethodId specifies an accessible subclass of the declaring
     // class rather than the declaring class itself.
-    DexCache* referrer_dex_cache = use_referrers_cache ? this->GetDexCache() : dex_cache;
+    const DexCache* referrer_dex_cache = use_referrers_cache ? this->GetDexCache() : dex_cache;
     uint32_t class_idx = referrer_dex_cache->GetDexFile()->GetMethodId(method_idx).class_idx_;
     // The referenced class has already been resolved with the method, get it from the dex cache.
     Class* dex_access_to = referrer_dex_cache->GetResolvedType(class_idx);
@@ -268,7 +268,7 @@
 }
 
 inline bool Class::CanAccessResolvedField(Class* access_to, ArtField* field,
-                                          DexCache& dex_cache, uint32_t field_idx) {
+                                          const DexCache& dex_cache, uint32_t field_idx) {
   return ResolvedFieldAccessTest<false, false>(access_to, field, field_idx, &dex_cache);
 }
 
@@ -278,7 +278,7 @@
 }
 
 inline bool Class::CanAccessResolvedMethod(Class* access_to, ArtMethod* method,
-                                           DexCache& dex_cache, uint32_t method_idx) {
+                                           const DexCache& dex_cache, uint32_t method_idx) {
   return ResolvedMethodAccessTest<false, false, kStatic>(access_to, method, method_idx, &dex_cache);
 }
 
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index 8071d79..a692381 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -454,7 +454,7 @@
   // Note that access to field's class is checked and this may require looking up the class
   // referenced by the FieldId in the DexFile in case the declaring class is inaccessible.
   bool CanAccessResolvedField(Class* access_to, ArtField* field,
-                              DexCache& dex_cache, uint32_t field_idx)
+                              const DexCache& dex_cache, uint32_t field_idx)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
   bool CheckResolvedFieldAccess(Class* access_to, ArtField* field,
                                 uint32_t field_idx)
@@ -464,7 +464,7 @@
   // Note that access to methods's class is checked and this may require looking up the class
   // referenced by the MethodId in the DexFile in case the declaring class is inaccessible.
   bool CanAccessResolvedMethod(Class* access_to, ArtMethod* resolved_method,
-                               DexCache& dex_cache, uint32_t method_idx)
+                               const DexCache& dex_cache, uint32_t method_idx)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
   template <InvokeType throw_invoke_type>
   bool CheckResolvedMethodAccess(Class* access_to, ArtMethod* resolved_method,
@@ -817,11 +817,11 @@
 
   template <bool throw_on_failure, bool use_referrers_cache>
   bool ResolvedFieldAccessTest(Class* access_to, ArtField* field,
-                               uint32_t field_idx, DexCache* dex_cache)
+                               uint32_t field_idx, const DexCache* dex_cache)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
   template <bool throw_on_failure, bool use_referrers_cache, InvokeType throw_invoke_type>
   bool ResolvedMethodAccessTest(Class* access_to, ArtMethod* resolved_method,
-                                uint32_t method_idx, DexCache* dex_cache)
+                                uint32_t method_idx, const DexCache* dex_cache)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
   bool Implements(const Class* klass) const