Merge "Move runtime/ to ClassAccessor"
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 16f2d0f..653e9ed 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -391,7 +391,7 @@
   DCHECK(driver.GetCompilerOptions().IsQuickeningCompilationEnabled());
   const char* descriptor = dex_file.GetClassDescriptor(class_def);
   ClassLinker* class_linker = runtime->GetClassLinker();
-  mirror::Class* klass = class_linker->FindClass(self, descriptor, class_loader);
+  ObjPtr<mirror::Class> klass = class_linker->FindClass(self, descriptor, class_loader);
   if (klass == nullptr) {
     CHECK(self->IsExceptionPending());
     self->ClearException();
diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc
index 856cb36..491e61f 100644
--- a/compiler/driver/compiler_driver_test.cc
+++ b/compiler/driver/compiler_driver_test.cc
@@ -88,7 +88,7 @@
       StackHandleScope<1> hs(soa.Self());
       Handle<mirror::ClassLoader> loader(
           hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader)));
-      mirror::Class* c = class_linker->FindClass(soa.Self(), descriptor, loader);
+      ObjPtr<mirror::Class> c = class_linker->FindClass(soa.Self(), descriptor, loader);
       CHECK(c != nullptr);
       const auto pointer_size = class_linker->GetImagePointerSize();
       for (auto& m : c->GetMethods(pointer_size)) {
@@ -115,14 +115,14 @@
   ObjPtr<mirror::DexCache> dex_cache = class_linker_->FindDexCache(soa.Self(), dex);
   EXPECT_EQ(dex.NumStringIds(), dex_cache->NumStrings());
   for (size_t i = 0; i < dex_cache->NumStrings(); i++) {
-    const mirror::String* string = dex_cache->GetResolvedString(dex::StringIndex(i));
+    const ObjPtr<mirror::String> string = dex_cache->GetResolvedString(dex::StringIndex(i));
     EXPECT_TRUE(string != nullptr) << "string_idx=" << i;
   }
   EXPECT_EQ(dex.NumTypeIds(), dex_cache->NumResolvedTypes());
   for (size_t i = 0; i < dex_cache->NumResolvedTypes(); i++) {
-    mirror::Class* type = dex_cache->GetResolvedType(dex::TypeIndex(i));
-    EXPECT_TRUE(type != nullptr) << "type_idx=" << i
-                              << " " << dex.GetTypeDescriptor(dex.GetTypeId(dex::TypeIndex(i)));
+    const ObjPtr<mirror::Class> type = dex_cache->GetResolvedType(dex::TypeIndex(i));
+    EXPECT_TRUE(type != nullptr)
+        << "type_idx=" << i << " " << dex.GetTypeDescriptor(dex.GetTypeId(dex::TypeIndex(i)));
   }
   EXPECT_TRUE(dex_cache->StaticMethodSize() == dex_cache->NumResolvedMethods()
       || dex.NumMethodIds() ==  dex_cache->NumResolvedMethods());
@@ -228,7 +228,7 @@
     StackHandleScope<1> hs(self);
     Handle<mirror::ClassLoader> h_loader(
         hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader)));
-    mirror::Class* klass = class_linker->FindClass(self, clazz.c_str(), h_loader);
+    ObjPtr<mirror::Class> klass = class_linker->FindClass(self, clazz.c_str(), h_loader);
     ASSERT_NE(klass, nullptr);
 
     const auto pointer_size = class_linker->GetImagePointerSize();
@@ -289,7 +289,7 @@
     StackHandleScope<1> hs(self);
     Handle<mirror::ClassLoader> h_loader(
         hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader)));
-    mirror::Class* klass = class_linker->FindClass(self, clazz.c_str(), h_loader);
+    ObjPtr<mirror::Class> klass = class_linker->FindClass(self, clazz.c_str(), h_loader);
     ASSERT_NE(klass, nullptr);
     EXPECT_TRUE(klass->IsVerified());
 
diff --git a/compiler/exception_test.cc b/compiler/exception_test.cc
index da1db45..15c0787 100644
--- a/compiler/exception_test.cc
+++ b/compiler/exception_test.cc
@@ -34,6 +34,7 @@
 #include "mirror/object_array-inl.h"
 #include "mirror/stack_trace_element.h"
 #include "oat_quick_method_header.h"
+#include "obj_ptr-inl.h"
 #include "optimizing/stack_map_stream.h"
 #include "runtime-inl.h"
 #include "scoped_thread_state_change-inl.h"
@@ -122,7 +123,7 @@
   ArtMethod* method_g_;
 
  private:
-  mirror::Class* my_klass_;
+  ObjPtr<mirror::Class> my_klass_;
 };
 
 TEST_F(ExceptionTest, FindCatchHandler) {
diff --git a/compiler/optimizing/intrinsics.cc b/compiler/optimizing/intrinsics.cc
index dfe6d79..056f533 100644
--- a/compiler/optimizing/intrinsics.cc
+++ b/compiler/optimizing/intrinsics.cc
@@ -272,7 +272,8 @@
   ClassLinker* class_linker = runtime->GetClassLinker();
   gc::Heap* heap = runtime->GetHeap();
   IntegerValueOfInfo info;
-  info.integer_cache = class_linker->FindSystemClass(self, "Ljava/lang/Integer$IntegerCache;");
+  info.integer_cache =
+      class_linker->FindSystemClass(self, "Ljava/lang/Integer$IntegerCache;").Ptr();
   if (info.integer_cache == nullptr) {
     self->ClearException();
     return info;
@@ -281,7 +282,7 @@
     // Optimization only works if the class is initialized and in the boot image.
     return info;
   }
-  info.integer = class_linker->FindSystemClass(self, "Ljava/lang/Integer;");
+  info.integer = class_linker->FindSystemClass(self, "Ljava/lang/Integer;").Ptr();
   if (info.integer == nullptr) {
     self->ClearException();
     return info;
diff --git a/compiler/optimizing/stack_map_test.cc b/compiler/optimizing/stack_map_test.cc
index 1127718..7178e66 100644
--- a/compiler/optimizing/stack_map_test.cc
+++ b/compiler/optimizing/stack_map_test.cc
@@ -45,6 +45,8 @@
 
 using Kind = DexRegisterLocation::Kind;
 
+constexpr static uint32_t kPcAlign = GetInstructionSetInstructionAlignment(kRuntimeISA);
+
 TEST(StackMapTest, Test1) {
   MallocArenaPool pool;
   ArenaStack arena_stack(&pool);
@@ -53,7 +55,7 @@
 
   ArenaBitVector sp_mask(&allocator, 0, false);
   size_t number_of_dex_registers = 2;
-  stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0);
+  stream.BeginStackMapEntry(0, 64 * kPcAlign, 0x3, &sp_mask, number_of_dex_registers, 0);
   stream.AddDexRegisterEntry(Kind::kInStack, 0);         // Short location.
   stream.AddDexRegisterEntry(Kind::kConstant, -2);       // Short location.
   stream.EndStackMapEntry();
@@ -77,9 +79,9 @@
 
   StackMap stack_map = code_info.GetStackMapAt(0);
   ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(0)));
-  ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64)));
+  ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64 * kPcAlign)));
   ASSERT_EQ(0u, stack_map.GetDexPc());
-  ASSERT_EQ(64u, stack_map.GetNativePcOffset(kRuntimeISA));
+  ASSERT_EQ(64u * kPcAlign, stack_map.GetNativePcOffset(kRuntimeISA));
   ASSERT_EQ(0x3u, code_info.GetRegisterMaskOf(stack_map));
 
   ASSERT_TRUE(CheckStackMask(code_info, stack_map, sp_mask));
@@ -131,7 +133,7 @@
   sp_mask1.SetBit(4);
   size_t number_of_dex_registers = 2;
   size_t number_of_dex_registers_in_inline_info = 0;
-  stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask1, number_of_dex_registers, 2);
+  stream.BeginStackMapEntry(0, 64 * kPcAlign, 0x3, &sp_mask1, number_of_dex_registers, 2);
   stream.AddDexRegisterEntry(Kind::kInStack, 0);         // Short location.
   stream.AddDexRegisterEntry(Kind::kConstant, -2);       // Large location.
   stream.BeginInlineInfoEntry(&art_method, 3, number_of_dex_registers_in_inline_info);
@@ -143,7 +145,7 @@
   ArenaBitVector sp_mask2(&allocator, 0, true);
   sp_mask2.SetBit(3);
   sp_mask2.SetBit(8);
-  stream.BeginStackMapEntry(1, 128, 0xFF, &sp_mask2, number_of_dex_registers, 0);
+  stream.BeginStackMapEntry(1, 128 * kPcAlign, 0xFF, &sp_mask2, number_of_dex_registers, 0);
   stream.AddDexRegisterEntry(Kind::kInRegister, 18);     // Short location.
   stream.AddDexRegisterEntry(Kind::kInFpuRegister, 3);   // Short location.
   stream.EndStackMapEntry();
@@ -151,7 +153,7 @@
   ArenaBitVector sp_mask3(&allocator, 0, true);
   sp_mask3.SetBit(1);
   sp_mask3.SetBit(5);
-  stream.BeginStackMapEntry(2, 192, 0xAB, &sp_mask3, number_of_dex_registers, 0);
+  stream.BeginStackMapEntry(2, 192 * kPcAlign, 0xAB, &sp_mask3, number_of_dex_registers, 0);
   stream.AddDexRegisterEntry(Kind::kInRegister, 6);       // Short location.
   stream.AddDexRegisterEntry(Kind::kInRegisterHigh, 8);   // Short location.
   stream.EndStackMapEntry();
@@ -159,7 +161,7 @@
   ArenaBitVector sp_mask4(&allocator, 0, true);
   sp_mask4.SetBit(6);
   sp_mask4.SetBit(7);
-  stream.BeginStackMapEntry(3, 256, 0xCD, &sp_mask4, number_of_dex_registers, 0);
+  stream.BeginStackMapEntry(3, 256 * kPcAlign, 0xCD, &sp_mask4, number_of_dex_registers, 0);
   stream.AddDexRegisterEntry(Kind::kInFpuRegister, 3);      // Short location, same in stack map 2.
   stream.AddDexRegisterEntry(Kind::kInFpuRegisterHigh, 1);  // Short location.
   stream.EndStackMapEntry();
@@ -185,9 +187,9 @@
   {
     StackMap stack_map = code_info.GetStackMapAt(0);
     ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(0)));
-    ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64)));
+    ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64 * kPcAlign)));
     ASSERT_EQ(0u, stack_map.GetDexPc());
-    ASSERT_EQ(64u, stack_map.GetNativePcOffset(kRuntimeISA));
+    ASSERT_EQ(64u * kPcAlign, stack_map.GetNativePcOffset(kRuntimeISA));
     ASSERT_EQ(0x3u, code_info.GetRegisterMaskOf(stack_map));
 
     ASSERT_TRUE(CheckStackMask(code_info, stack_map, sp_mask1));
@@ -237,9 +239,9 @@
   {
     StackMap stack_map = code_info.GetStackMapAt(1);
     ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(1u)));
-    ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(128u)));
+    ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(128u * kPcAlign)));
     ASSERT_EQ(1u, stack_map.GetDexPc());
-    ASSERT_EQ(128u, stack_map.GetNativePcOffset(kRuntimeISA));
+    ASSERT_EQ(128u * kPcAlign, stack_map.GetNativePcOffset(kRuntimeISA));
     ASSERT_EQ(0xFFu, code_info.GetRegisterMaskOf(stack_map));
 
     ASSERT_TRUE(CheckStackMask(code_info, stack_map, sp_mask2));
@@ -283,9 +285,9 @@
   {
     StackMap stack_map = code_info.GetStackMapAt(2);
     ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(2u)));
-    ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(192u)));
+    ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(192u * kPcAlign)));
     ASSERT_EQ(2u, stack_map.GetDexPc());
-    ASSERT_EQ(192u, stack_map.GetNativePcOffset(kRuntimeISA));
+    ASSERT_EQ(192u * kPcAlign, stack_map.GetNativePcOffset(kRuntimeISA));
     ASSERT_EQ(0xABu, code_info.GetRegisterMaskOf(stack_map));
 
     ASSERT_TRUE(CheckStackMask(code_info, stack_map, sp_mask3));
@@ -329,9 +331,9 @@
   {
     StackMap stack_map = code_info.GetStackMapAt(3);
     ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(3u)));
-    ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(256u)));
+    ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(256u * kPcAlign)));
     ASSERT_EQ(3u, stack_map.GetDexPc());
-    ASSERT_EQ(256u, stack_map.GetNativePcOffset(kRuntimeISA));
+    ASSERT_EQ(256u * kPcAlign, stack_map.GetNativePcOffset(kRuntimeISA));
     ASSERT_EQ(0xCDu, code_info.GetRegisterMaskOf(stack_map));
 
     ASSERT_TRUE(CheckStackMask(code_info, stack_map, sp_mask4));
@@ -384,7 +386,7 @@
   sp_mask1.SetBit(4);
   const size_t number_of_dex_registers = 2;
   const size_t number_of_dex_registers_in_inline_info = 2;
-  stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask1, number_of_dex_registers, 1);
+  stream.BeginStackMapEntry(0, 64 * kPcAlign, 0x3, &sp_mask1, number_of_dex_registers, 1);
   stream.AddDexRegisterEntry(Kind::kInStack, 0);         // Short location.
   stream.AddDexRegisterEntry(Kind::kConstant, -2);       // Large location.
   stream.BeginInlineInfoEntry(&art_method, 3, number_of_dex_registers_in_inline_info);
@@ -414,9 +416,9 @@
   {
     StackMap stack_map = code_info.GetStackMapAt(0);
     ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(0)));
-    ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64)));
+    ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64 * kPcAlign)));
     ASSERT_EQ(0u, stack_map.GetDexPc());
-    ASSERT_EQ(64u, stack_map.GetNativePcOffset(kRuntimeISA));
+    ASSERT_EQ(64u * kPcAlign, stack_map.GetNativePcOffset(kRuntimeISA));
     ASSERT_EQ(0x3u, code_info.GetRegisterMaskOf(stack_map));
 
     ASSERT_TRUE(CheckStackMask(code_info, stack_map, sp_mask1));
@@ -469,7 +471,7 @@
 
   ArenaBitVector sp_mask(&allocator, 0, false);
   uint32_t number_of_dex_registers = 2;
-  stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0);
+  stream.BeginStackMapEntry(0, 64 * kPcAlign, 0x3, &sp_mask, number_of_dex_registers, 0);
   stream.AddDexRegisterEntry(Kind::kNone, 0);            // No location.
   stream.AddDexRegisterEntry(Kind::kConstant, -2);       // Large location.
   stream.EndStackMapEntry();
@@ -492,9 +494,9 @@
 
   StackMap stack_map = code_info.GetStackMapAt(0);
   ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(0)));
-  ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64)));
+  ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64 * kPcAlign)));
   ASSERT_EQ(0u, stack_map.GetDexPc());
-  ASSERT_EQ(64u, stack_map.GetNativePcOffset(kRuntimeISA));
+  ASSERT_EQ(64u * kPcAlign, stack_map.GetNativePcOffset(kRuntimeISA));
   ASSERT_EQ(0x3u, code_info.GetRegisterMaskOf(stack_map));
 
   ASSERT_TRUE(stack_map.HasDexRegisterMap());
@@ -543,7 +545,7 @@
   ArenaBitVector sp_mask(&allocator, 0, false);
   uint32_t number_of_dex_registers = 1024;
   // Create the first stack map (and its Dex register map).
-  stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0);
+  stream.BeginStackMapEntry(0, 64 * kPcAlign, 0x3, &sp_mask, number_of_dex_registers, 0);
   uint32_t number_of_dex_live_registers_in_dex_register_map_0 = number_of_dex_registers - 8;
   for (uint32_t i = 0; i < number_of_dex_live_registers_in_dex_register_map_0; ++i) {
     // Use two different Dex register locations to populate this map,
@@ -554,7 +556,7 @@
   }
   stream.EndStackMapEntry();
   // Create the second stack map (and its Dex register map).
-  stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0);
+  stream.BeginStackMapEntry(0, 64 * kPcAlign, 0x3, &sp_mask, number_of_dex_registers, 0);
   for (uint32_t i = 0; i < number_of_dex_registers; ++i) {
     stream.AddDexRegisterEntry(Kind::kConstant, 0);  // Short location.
   }
@@ -605,17 +607,17 @@
   ArenaBitVector sp_mask(&allocator, 0, false);
   uint32_t number_of_dex_registers = 2;
   // First stack map.
-  stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0);
+  stream.BeginStackMapEntry(0, 64 * kPcAlign, 0x3, &sp_mask, number_of_dex_registers, 0);
   stream.AddDexRegisterEntry(Kind::kInRegister, 0);  // Short location.
   stream.AddDexRegisterEntry(Kind::kConstant, -2);   // Large location.
   stream.EndStackMapEntry();
   // Second stack map, which should share the same dex register map.
-  stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0);
+  stream.BeginStackMapEntry(0, 64 * kPcAlign, 0x3, &sp_mask, number_of_dex_registers, 0);
   stream.AddDexRegisterEntry(Kind::kInRegister, 0);  // Short location.
   stream.AddDexRegisterEntry(Kind::kConstant, -2);   // Large location.
   stream.EndStackMapEntry();
   // Third stack map (doesn't share the dex register map).
-  stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0);
+  stream.BeginStackMapEntry(0, 64 * kPcAlign, 0x3, &sp_mask, number_of_dex_registers, 0);
   stream.AddDexRegisterEntry(Kind::kInRegister, 2);  // Short location.
   stream.AddDexRegisterEntry(Kind::kConstant, -2);   // Large location.
   stream.EndStackMapEntry();
@@ -662,11 +664,11 @@
 
   ArenaBitVector sp_mask(&allocator, 0, false);
   uint32_t number_of_dex_registers = 0;
-  stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0);
+  stream.BeginStackMapEntry(0, 64 * kPcAlign, 0x3, &sp_mask, number_of_dex_registers, 0);
   stream.EndStackMapEntry();
 
   number_of_dex_registers = 1;
-  stream.BeginStackMapEntry(1, 68, 0x4, &sp_mask, number_of_dex_registers, 0);
+  stream.BeginStackMapEntry(1, 68 * kPcAlign, 0x4, &sp_mask, number_of_dex_registers, 0);
   stream.EndStackMapEntry();
 
   size_t size = stream.PrepareForFillIn();
@@ -684,9 +686,9 @@
 
   StackMap stack_map = code_info.GetStackMapAt(0);
   ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(0)));
-  ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64)));
+  ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64 * kPcAlign)));
   ASSERT_EQ(0u, stack_map.GetDexPc());
-  ASSERT_EQ(64u, stack_map.GetNativePcOffset(kRuntimeISA));
+  ASSERT_EQ(64u * kPcAlign, stack_map.GetNativePcOffset(kRuntimeISA));
   ASSERT_EQ(0x3u, code_info.GetRegisterMaskOf(stack_map));
 
   ASSERT_FALSE(stack_map.HasDexRegisterMap());
@@ -694,9 +696,9 @@
 
   stack_map = code_info.GetStackMapAt(1);
   ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(1)));
-  ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(68)));
+  ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(68 * kPcAlign)));
   ASSERT_EQ(1u, stack_map.GetDexPc());
-  ASSERT_EQ(68u, stack_map.GetNativePcOffset(kRuntimeISA));
+  ASSERT_EQ(68u * kPcAlign, stack_map.GetNativePcOffset(kRuntimeISA));
   ASSERT_EQ(0x4u, code_info.GetRegisterMaskOf(stack_map));
 
   ASSERT_FALSE(stack_map.HasDexRegisterMap());
@@ -715,7 +717,7 @@
   sp_mask1.SetBit(4);
 
   // First stack map.
-  stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask1, 2, 2);
+  stream.BeginStackMapEntry(0, 64 * kPcAlign, 0x3, &sp_mask1, 2, 2);
   stream.AddDexRegisterEntry(Kind::kInStack, 0);
   stream.AddDexRegisterEntry(Kind::kConstant, 4);
 
@@ -731,7 +733,7 @@
   stream.EndStackMapEntry();
 
   // Second stack map.
-  stream.BeginStackMapEntry(2, 22, 0x3, &sp_mask1, 2, 3);
+  stream.BeginStackMapEntry(2, 22 * kPcAlign, 0x3, &sp_mask1, 2, 3);
   stream.AddDexRegisterEntry(Kind::kInStack, 56);
   stream.AddDexRegisterEntry(Kind::kConstant, 0);
 
@@ -749,13 +751,13 @@
   stream.EndStackMapEntry();
 
   // Third stack map.
-  stream.BeginStackMapEntry(4, 56, 0x3, &sp_mask1, 2, 0);
+  stream.BeginStackMapEntry(4, 56 * kPcAlign, 0x3, &sp_mask1, 2, 0);
   stream.AddDexRegisterEntry(Kind::kNone, 0);
   stream.AddDexRegisterEntry(Kind::kConstant, 4);
   stream.EndStackMapEntry();
 
   // Fourth stack map.
-  stream.BeginStackMapEntry(6, 78, 0x3, &sp_mask1, 2, 3);
+  stream.BeginStackMapEntry(6, 78 * kPcAlign, 0x3, &sp_mask1, 2, 3);
   stream.AddDexRegisterEntry(Kind::kInStack, 56);
   stream.AddDexRegisterEntry(Kind::kConstant, 0);
 
@@ -904,9 +906,9 @@
   ArenaBitVector sp_mask(&allocator, 0, true);
   sp_mask.SetBit(1);
   sp_mask.SetBit(4);
-  stream.BeginStackMapEntry(0, 4, 0x3, &sp_mask, 0, 0);
+  stream.BeginStackMapEntry(0, 4 * kPcAlign, 0x3, &sp_mask, 0, 0);
   stream.EndStackMapEntry();
-  stream.BeginStackMapEntry(0, 8, 0x3, &sp_mask, 0, 0);
+  stream.BeginStackMapEntry(0, 8 * kPcAlign, 0x3, &sp_mask, 0, 0);
   stream.EndStackMapEntry();
 
   size_t size = stream.PrepareForFillIn();
@@ -917,8 +919,8 @@
   CodeInfo code_info(region);
   ASSERT_EQ(2u, code_info.GetNumberOfStackMaps());
 
-  StackMap stack_map1 = code_info.GetStackMapForNativePcOffset(4);
-  StackMap stack_map2 = code_info.GetStackMapForNativePcOffset(8);
+  StackMap stack_map1 = code_info.GetStackMapForNativePcOffset(4 * kPcAlign);
+  StackMap stack_map2 = code_info.GetStackMapForNativePcOffset(8 * kPcAlign);
   EXPECT_EQ(stack_map1.GetStackMaskIndex(),
             stack_map2.GetStackMaskIndex());
 }
@@ -931,13 +933,13 @@
 
   ArenaBitVector sp_mask(&allocator, 0, true);
   sp_mask.SetBit(1);
-  stream.BeginStackMapEntry(0, 4, 0x3, &sp_mask, 0, 0);
+  stream.BeginStackMapEntry(0, 4 * kPcAlign, 0x3, &sp_mask, 0, 0);
   stream.AddInvoke(kSuper, 1);
   stream.EndStackMapEntry();
-  stream.BeginStackMapEntry(0, 8, 0x3, &sp_mask, 0, 0);
+  stream.BeginStackMapEntry(0, 8 * kPcAlign, 0x3, &sp_mask, 0, 0);
   stream.AddInvoke(kStatic, 3);
   stream.EndStackMapEntry();
-  stream.BeginStackMapEntry(0, 16, 0x3, &sp_mask, 0, 0);
+  stream.BeginStackMapEntry(0, 16 * kPcAlign, 0x3, &sp_mask, 0, 0);
   stream.AddInvoke(kDirect, 65535);
   stream.EndStackMapEntry();
 
@@ -954,9 +956,9 @@
   MethodInfo method_info(method_info_region.begin());
   ASSERT_EQ(3u, code_info.GetNumberOfStackMaps());
 
-  InvokeInfo invoke1(code_info.GetInvokeInfoForNativePcOffset(4));
-  InvokeInfo invoke2(code_info.GetInvokeInfoForNativePcOffset(8));
-  InvokeInfo invoke3(code_info.GetInvokeInfoForNativePcOffset(16));
+  InvokeInfo invoke1(code_info.GetInvokeInfoForNativePcOffset(4 * kPcAlign));
+  InvokeInfo invoke2(code_info.GetInvokeInfoForNativePcOffset(8 * kPcAlign));
+  InvokeInfo invoke3(code_info.GetInvokeInfoForNativePcOffset(16 * kPcAlign));
   InvokeInfo invoke_invalid(code_info.GetInvokeInfoForNativePcOffset(12));
   EXPECT_FALSE(invoke_invalid.IsValid());  // No entry for that index.
   EXPECT_TRUE(invoke1.IsValid());
@@ -964,13 +966,13 @@
   EXPECT_TRUE(invoke3.IsValid());
   EXPECT_EQ(invoke1.GetInvokeType(), kSuper);
   EXPECT_EQ(invoke1.GetMethodIndex(method_info), 1u);
-  EXPECT_EQ(invoke1.GetNativePcOffset(kRuntimeISA), 4u);
+  EXPECT_EQ(invoke1.GetNativePcOffset(kRuntimeISA), 4u * kPcAlign);
   EXPECT_EQ(invoke2.GetInvokeType(), kStatic);
   EXPECT_EQ(invoke2.GetMethodIndex(method_info), 3u);
-  EXPECT_EQ(invoke2.GetNativePcOffset(kRuntimeISA), 8u);
+  EXPECT_EQ(invoke2.GetNativePcOffset(kRuntimeISA), 8u * kPcAlign);
   EXPECT_EQ(invoke3.GetInvokeType(), kDirect);
   EXPECT_EQ(invoke3.GetMethodIndex(method_info), 65535u);
-  EXPECT_EQ(invoke3.GetNativePcOffset(kRuntimeISA), 16u);
+  EXPECT_EQ(invoke3.GetNativePcOffset(kRuntimeISA), 16u * kPcAlign);
 }
 
 }  // namespace art
diff --git a/compiler/verifier_deps_test.cc b/compiler/verifier_deps_test.cc
index c0892ff..3fe2ec0 100644
--- a/compiler/verifier_deps_test.cc
+++ b/compiler/verifier_deps_test.cc
@@ -65,17 +65,16 @@
     callbacks_.reset(new VerifierDepsCompilerCallbacks());
   }
 
-  mirror::Class* FindClassByName(const std::string& name, ScopedObjectAccess* soa)
+  ObjPtr<mirror::Class> FindClassByName(ScopedObjectAccess& soa, const std::string& name)
       REQUIRES_SHARED(Locks::mutator_lock_) {
-    StackHandleScope<1> hs(Thread::Current());
+    StackHandleScope<1> hs(soa.Self());
     Handle<mirror::ClassLoader> class_loader_handle(
-        hs.NewHandle(soa->Decode<mirror::ClassLoader>(class_loader_)));
-    mirror::Class* klass = class_linker_->FindClass(Thread::Current(),
-                                                    name.c_str(),
-                                                    class_loader_handle);
+        hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader_)));
+    ObjPtr<mirror::Class> klass =
+        class_linker_->FindClass(soa.Self(), name.c_str(), class_loader_handle);
     if (klass == nullptr) {
-      DCHECK(Thread::Current()->IsExceptionPending());
-      Thread::Current()->ClearException();
+      DCHECK(soa.Self()->IsExceptionPending());
+      soa.Self()->ClearException();
     }
     return klass;
   }
@@ -114,16 +113,16 @@
     callbacks->SetVerifierDeps(verifier_deps_.get());
   }
 
-  void LoadDexFile(ScopedObjectAccess* soa, const char* name1, const char* name2 = nullptr)
+  void LoadDexFile(ScopedObjectAccess& soa, const char* name1, const char* name2 = nullptr)
       REQUIRES_SHARED(Locks::mutator_lock_) {
     class_loader_ = (name2 == nullptr) ? LoadDex(name1) : LoadMultiDex(name1, name2);
     dex_files_ = GetDexFiles(class_loader_);
     primary_dex_file_ = dex_files_.front();
 
     SetVerifierDeps(dex_files_);
-    StackHandleScope<1> hs(soa->Self());
+    StackHandleScope<1> hs(soa.Self());
     Handle<mirror::ClassLoader> loader =
-        hs.NewHandle(soa->Decode<mirror::ClassLoader>(class_loader_));
+        hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader_));
     for (const DexFile* dex_file : dex_files_) {
       class_linker_->RegisterDexFile(*dex_file, loader.Get());
     }
@@ -133,16 +132,16 @@
     compiler_driver_->SetDexFilesForOatFile(dex_files_);
   }
 
-  void LoadDexFile(ScopedObjectAccess* soa) REQUIRES_SHARED(Locks::mutator_lock_) {
+  void LoadDexFile(ScopedObjectAccess& soa) REQUIRES_SHARED(Locks::mutator_lock_) {
     LoadDexFile(soa, "VerifierDeps");
     CHECK_EQ(dex_files_.size(), 1u);
-    klass_Main_ = FindClassByName("LMain;", soa);
+    klass_Main_ = FindClassByName(soa, "LMain;");
     CHECK(klass_Main_ != nullptr);
   }
 
   bool VerifyMethod(const std::string& method_name) {
     ScopedObjectAccess soa(Thread::Current());
-    LoadDexFile(&soa);
+    LoadDexFile(soa);
 
     StackHandleScope<2> hs(soa.Self());
     Handle<mirror::ClassLoader> class_loader_handle(
@@ -193,7 +192,7 @@
   void VerifyDexFile(const char* multidex = nullptr) {
     {
       ScopedObjectAccess soa(Thread::Current());
-      LoadDexFile(&soa, "VerifierDeps", multidex);
+      LoadDexFile(soa, "VerifierDeps", multidex);
     }
     SetupCompilerDriver();
     VerifyWithCompilerDriver(/* verifier_deps */ nullptr);
@@ -204,13 +203,14 @@
                                   bool is_strict,
                                   bool is_assignable) {
     ScopedObjectAccess soa(Thread::Current());
-    LoadDexFile(&soa);
-    mirror::Class* klass_dst = FindClassByName(dst, &soa);
+    LoadDexFile(soa);
+    StackHandleScope<1> hs(soa.Self());
+    Handle<mirror::Class> klass_dst = hs.NewHandle(FindClassByName(soa, dst));
     DCHECK(klass_dst != nullptr) << dst;
-    mirror::Class* klass_src = FindClassByName(src, &soa);
+    ObjPtr<mirror::Class> klass_src = FindClassByName(soa, src);
     DCHECK(klass_src != nullptr) << src;
     verifier_deps_->AddAssignability(*primary_dex_file_,
-                                     klass_dst,
+                                     klass_dst.Get(),
                                      klass_src,
                                      is_strict,
                                      is_assignable);
@@ -453,12 +453,12 @@
   std::vector<const DexFile*> dex_files_;
   const DexFile* primary_dex_file_;
   jobject class_loader_;
-  mirror::Class* klass_Main_;
+  ObjPtr<mirror::Class> klass_Main_;
 };
 
 TEST_F(VerifierDepsTest, StringToId) {
   ScopedObjectAccess soa(Thread::Current());
-  LoadDexFile(&soa);
+  LoadDexFile(soa);
 
   dex::StringIndex id_Main1 = verifier_deps_->GetIdFromString(*primary_dex_file_, "LMain;");
   ASSERT_LT(id_Main1.index_, primary_dex_file_->NumStringIds());
@@ -1441,7 +1441,7 @@
     for (bool verify_failure : { false, true }) {
       {
         ScopedObjectAccess soa(Thread::Current());
-        LoadDexFile(&soa, "VerifierDeps", multi);
+        LoadDexFile(soa, "VerifierDeps", multi);
       }
       VerifyWithCompilerDriver(/* verifier_deps */ nullptr);
 
@@ -1450,7 +1450,7 @@
 
       {
         ScopedObjectAccess soa(Thread::Current());
-        LoadDexFile(&soa, "VerifierDeps", multi);
+        LoadDexFile(soa, "VerifierDeps", multi);
       }
       verifier::VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
       if (verify_failure) {
diff --git a/dex2oat/linker/image_test.cc b/dex2oat/linker/image_test.cc
index ab6e7a8..96c48b8 100644
--- a/dex2oat/linker/image_test.cc
+++ b/dex2oat/linker/image_test.cc
@@ -111,18 +111,18 @@
 
   // Test the pointer to quick code is the same in origin method
   // and in the copied method form the same oat file.
-  mirror::Class* iface_klass = class_linker_->LookupClass(
-      self, "LIface;", ObjPtr<mirror::ClassLoader>());
+  ObjPtr<mirror::Class> iface_klass =
+      class_linker_->LookupClass(self, "LIface;", /* class_loader */ nullptr);
   ASSERT_NE(nullptr, iface_klass);
   ArtMethod* origin = iface_klass->FindInterfaceMethod("defaultMethod", "()V", pointer_size);
   ASSERT_NE(nullptr, origin);
-  ASSERT_TRUE(origin->GetDeclaringClass() == iface_klass);
+  ASSERT_OBJ_PTR_EQ(origin->GetDeclaringClass(), iface_klass);
   const void* code = origin->GetEntryPointFromQuickCompiledCodePtrSize(pointer_size);
   // The origin method should have a pointer to quick code
   ASSERT_NE(nullptr, code);
   ASSERT_FALSE(class_linker_->IsQuickToInterpreterBridge(code));
-  mirror::Class* impl_klass = class_linker_->LookupClass(
-      self, "LImpl;", ObjPtr<mirror::ClassLoader>());
+  ObjPtr<mirror::Class> impl_klass =
+      class_linker_->LookupClass(self, "LImpl;", /* class_loader */ nullptr);
   ASSERT_NE(nullptr, impl_klass);
   ArtMethod* copied = FindCopiedMethod(origin, impl_klass);
   ASSERT_NE(nullptr, copied);
@@ -132,20 +132,20 @@
   // Test the origin method has pointer to quick code
   // but the copied method has pointer to interpreter
   // because these methods are in different oat files.
-  mirror::Class* iterable_klass = class_linker_->LookupClass(
-      self, "Ljava/lang/Iterable;", ObjPtr<mirror::ClassLoader>());
+  ObjPtr<mirror::Class> iterable_klass =
+      class_linker_->LookupClass(self, "Ljava/lang/Iterable;", /* class_loader */ nullptr);
   ASSERT_NE(nullptr, iterable_klass);
   origin = iterable_klass->FindClassMethod(
       "forEach", "(Ljava/util/function/Consumer;)V", pointer_size);
   ASSERT_NE(nullptr, origin);
   ASSERT_FALSE(origin->IsDirect());
-  ASSERT_TRUE(origin->GetDeclaringClass() == iterable_klass);
+  ASSERT_OBJ_PTR_EQ(origin->GetDeclaringClass(), iterable_klass);
   code = origin->GetEntryPointFromQuickCompiledCodePtrSize(pointer_size);
   // the origin method should have a pointer to quick code
   ASSERT_NE(nullptr, code);
   ASSERT_FALSE(class_linker_->IsQuickToInterpreterBridge(code));
-  mirror::Class* iterablebase_klass = class_linker_->LookupClass(
-      self, "LIterableBase;", ObjPtr<mirror::ClassLoader>());
+  ObjPtr<mirror::Class> iterablebase_klass =
+      class_linker_->LookupClass(self, "LIterableBase;", /* class_loader */ nullptr);
   ASSERT_NE(nullptr, iterablebase_klass);
   copied = FindCopiedMethod(origin, iterablebase_klass);
   ASSERT_NE(nullptr, copied);
diff --git a/dex2oat/linker/image_test.h b/dex2oat/linker/image_test.h
index 4b231ed..f0daf69 100644
--- a/dex2oat/linker/image_test.h
+++ b/dex2oat/linker/image_test.h
@@ -97,7 +97,7 @@
     return new std::unordered_set<std::string>(image_classes_);
   }
 
-  ArtMethod* FindCopiedMethod(ArtMethod* origin, mirror::Class* klass)
+  ArtMethod* FindCopiedMethod(ArtMethod* origin, ObjPtr<mirror::Class> klass)
       REQUIRES_SHARED(Locks::mutator_lock_) {
     PointerSize pointer_size = class_linker_->GetImagePointerSize();
     for (ArtMethod& m : klass->GetCopiedMethods(pointer_size)) {
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index 1f197b8..6b626c2 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -41,6 +41,7 @@
 #include "base/unix_file/fd_file.h"
 #include "class_linker-inl.h"
 #include "class_linker.h"
+#include "class_root.h"
 #include "compiled_method.h"
 #include "debug/debug_info.h"
 #include "debug/elf_debug_writer.h"
@@ -3253,7 +3254,7 @@
       PrepareClass(runtime, klass, prepared);
     }
 
-    mirror::Class* object_class = mirror::Class::GetJavaLangClass()->GetSuperClass();
+    ObjPtr<mirror::Class> object_class = GetClassRoot<mirror::Object>();
     DCHECK(object_class->IsObjectClass());
 
     bool result = klass->GetImt(pointer_size) == object_class->GetImt(pointer_size);
@@ -3287,8 +3288,8 @@
                                        Handle<mirror::ClassLoader> h_loader,
                                        const std::string& class_name,
                                        const PointerSize pointer_size,
-                                       mirror::Class** klass_out,
-                                       std::unordered_set<std::string>* prepared)
+                                       /*out*/ ObjPtr<mirror::Class>* klass_out,
+                                       /*inout*/ std::unordered_set<std::string>* prepared)
       REQUIRES_SHARED(Locks::mutator_lock_) {
     if (class_name.empty()) {
       return nullptr;
@@ -3301,7 +3302,8 @@
       descriptor = DotToDescriptor(class_name.c_str());
     }
 
-    mirror::Class* klass = runtime->GetClassLinker()->FindClass(self, descriptor.c_str(), h_loader);
+    ObjPtr<mirror::Class> klass =
+        runtime->GetClassLinker()->FindClass(self, descriptor.c_str(), h_loader);
 
     if (klass == nullptr) {
       self->ClearException();
@@ -3321,7 +3323,7 @@
   static ImTable* PrepareAndGetImTable(Runtime* runtime,
                                        Handle<mirror::Class> h_klass,
                                        const PointerSize pointer_size,
-                                       std::unordered_set<std::string>* prepared)
+                                       /*inout*/ std::unordered_set<std::string>* prepared)
       REQUIRES_SHARED(Locks::mutator_lock_) {
     PrepareClass(runtime, h_klass, prepared);
     return h_klass->GetImt(pointer_size);
@@ -3333,7 +3335,7 @@
                               std::unordered_set<std::string>* prepared)
       REQUIRES_SHARED(Locks::mutator_lock_) {
     const PointerSize pointer_size = runtime->GetClassLinker()->GetImagePointerSize();
-    mirror::Class* klass;
+    ObjPtr<mirror::Class> klass;
     ImTable* imt = PrepareAndGetImTable(runtime,
                                         Thread::Current(),
                                         h_loader,
@@ -3389,10 +3391,10 @@
                                const std::string& class_name,
                                const std::string& method,
                                Handle<mirror::ClassLoader> h_loader,
-                               std::unordered_set<std::string>* prepared)
+                               /*inout*/ std::unordered_set<std::string>* prepared)
       REQUIRES_SHARED(Locks::mutator_lock_) {
     const PointerSize pointer_size = runtime->GetClassLinker()->GetImagePointerSize();
-    mirror::Class* klass;
+    ObjPtr<mirror::Class> klass;
     ImTable* imt = PrepareAndGetImTable(runtime,
                                         Thread::Current(),
                                         h_loader,
@@ -3495,7 +3497,7 @@
   // and note in the given set that the work was done.
   static void PrepareClass(Runtime* runtime,
                            Handle<mirror::Class> h_klass,
-                           std::unordered_set<std::string>* done)
+                           /*inout*/ std::unordered_set<std::string>* done)
       REQUIRES_SHARED(Locks::mutator_lock_) {
     if (!h_klass->ShouldHaveImt()) {
       return;
diff --git a/profman/profile_assistant_test.cc b/profman/profile_assistant_test.cc
index bd44e49..370f59d 100644
--- a/profman/profile_assistant_test.cc
+++ b/profman/profile_assistant_test.cc
@@ -22,6 +22,7 @@
 #include "base/utils.h"
 #include "common_runtime_test.h"
 #include "dex/descriptors_names.h"
+#include "dex/type_reference.h"
 #include "exec_utils.h"
 #include "linear_alloc.h"
 #include "mirror/class-inl.h"
@@ -33,6 +34,7 @@
 namespace art {
 
 using Hotness = ProfileCompilationInfo::MethodHotness;
+using TypeReferenceSet = std::set<TypeReference, TypeReferenceValueComparator>;
 
 static constexpr size_t kMaxMethodIds = 65535;
 
@@ -308,25 +310,24 @@
     return true;
   }
 
-  mirror::Class* GetClass(jobject class_loader, const std::string& clazz) {
+  ObjPtr<mirror::Class> GetClass(ScopedObjectAccess& soa,
+                                 jobject class_loader,
+                                 const std::string& clazz) REQUIRES_SHARED(Locks::mutator_lock_) {
     ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
-    Thread* self = Thread::Current();
-    ScopedObjectAccess soa(self);
-    StackHandleScope<1> hs(self);
-    Handle<mirror::ClassLoader> h_loader(
-        hs.NewHandle(ObjPtr<mirror::ClassLoader>::DownCast(self->DecodeJObject(class_loader))));
-    return class_linker->FindClass(self, clazz.c_str(), h_loader);
+    StackHandleScope<1> hs(soa.Self());
+    Handle<mirror::ClassLoader> h_loader(hs.NewHandle(
+        ObjPtr<mirror::ClassLoader>::DownCast(soa.Self()->DecodeJObject(class_loader))));
+    return class_linker->FindClass(soa.Self(), clazz.c_str(), h_loader);
   }
 
   ArtMethod* GetVirtualMethod(jobject class_loader,
                               const std::string& clazz,
                               const std::string& name) {
-    mirror::Class* klass = GetClass(class_loader, clazz);
+    ScopedObjectAccess soa(Thread::Current());
+    ObjPtr<mirror::Class> klass = GetClass(soa, class_loader, clazz);
     ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
     const auto pointer_size = class_linker->GetImagePointerSize();
     ArtMethod* method = nullptr;
-    Thread* self = Thread::Current();
-    ScopedObjectAccess soa(self);
     for (auto& m : klass->GetVirtualMethods(pointer_size)) {
       if (name == m.GetName()) {
         EXPECT_TRUE(method == nullptr);
@@ -336,9 +337,14 @@
     return method;
   }
 
+  static TypeReference MakeTypeReference(ObjPtr<mirror::Class> klass)
+      REQUIRES_SHARED(Locks::mutator_lock_) {
+    return TypeReference(&klass->GetDexFile(), klass->GetDexTypeIndex());
+  }
+
   // Verify that given method has the expected inline caches and nothing else.
   void AssertInlineCaches(ArtMethod* method,
-                          const std::set<mirror::Class*>& expected_clases,
+                          const TypeReferenceSet& expected_clases,
                           const ProfileCompilationInfo& info,
                           bool is_megamorphic,
                           bool is_missing_types)
@@ -355,12 +361,11 @@
     ASSERT_EQ(dex_pc_data.is_missing_types, is_missing_types);
     ASSERT_EQ(expected_clases.size(), dex_pc_data.classes.size());
     size_t found = 0;
-    for (mirror::Class* it : expected_clases) {
+    for (const TypeReference& type_ref : expected_clases) {
       for (const auto& class_ref : dex_pc_data.classes) {
         ProfileCompilationInfo::DexReference dex_ref =
             pmi->dex_references[class_ref.dex_profile_index];
-        if (dex_ref.MatchesDex(&(it->GetDexFile())) &&
-            class_ref.type_index == it->GetDexTypeIndex()) {
+        if (dex_ref.MatchesDex(type_ref.dex_file) && class_ref.type_index == type_ref.TypeIndex()) {
           found++;
         }
       }
@@ -715,7 +720,7 @@
   ASSERT_TRUE(info.Load(GetFd(profile_file)));
   // Verify that the profile has matching methods.
   ScopedObjectAccess soa(Thread::Current());
-  ObjPtr<mirror::Class> klass = GetClass(nullptr, "Ljava/lang/Math;");
+  ObjPtr<mirror::Class> klass = GetClass(soa, /* class_loader */ nullptr, "Ljava/lang/Math;");
   ASSERT_TRUE(klass != nullptr);
   size_t method_count = 0;
   for (ArtMethod& method : klass->GetMethods(kRuntimePointerSize)) {
@@ -907,9 +912,10 @@
   jobject class_loader = LoadDex("ProfileTestMultiDex");
   ASSERT_NE(class_loader, nullptr);
 
-  mirror::Class* sub_a = GetClass(class_loader, "LSubA;");
-  mirror::Class* sub_b = GetClass(class_loader, "LSubB;");
-  mirror::Class* sub_c = GetClass(class_loader, "LSubC;");
+  StackHandleScope<3> hs(soa.Self());
+  Handle<mirror::Class> sub_a = hs.NewHandle(GetClass(soa, class_loader, "LSubA;"));
+  Handle<mirror::Class> sub_b = hs.NewHandle(GetClass(soa, class_loader, "LSubB;"));
+  Handle<mirror::Class> sub_c = hs.NewHandle(GetClass(soa, class_loader, "LSubC;"));
 
   ASSERT_TRUE(sub_a != nullptr);
   ASSERT_TRUE(sub_b != nullptr);
@@ -921,8 +927,8 @@
                                                      "LTestInline;",
                                                      "inlineMonomorphic");
     ASSERT_TRUE(inline_monomorphic != nullptr);
-    std::set<mirror::Class*> expected_monomorphic;
-    expected_monomorphic.insert(sub_a);
+    TypeReferenceSet expected_monomorphic;
+    expected_monomorphic.insert(MakeTypeReference(sub_a.Get()));
     AssertInlineCaches(inline_monomorphic,
                        expected_monomorphic,
                        info,
@@ -936,10 +942,10 @@
                                                     "LTestInline;",
                                                     "inlinePolymorphic");
     ASSERT_TRUE(inline_polymorhic != nullptr);
-    std::set<mirror::Class*> expected_polymorphic;
-    expected_polymorphic.insert(sub_a);
-    expected_polymorphic.insert(sub_b);
-    expected_polymorphic.insert(sub_c);
+    TypeReferenceSet expected_polymorphic;
+    expected_polymorphic.insert(MakeTypeReference(sub_a.Get()));
+    expected_polymorphic.insert(MakeTypeReference(sub_b.Get()));
+    expected_polymorphic.insert(MakeTypeReference(sub_c.Get()));
     AssertInlineCaches(inline_polymorhic,
                        expected_polymorphic,
                        info,
@@ -953,7 +959,7 @@
                                                      "LTestInline;",
                                                      "inlineMegamorphic");
     ASSERT_TRUE(inline_megamorphic != nullptr);
-    std::set<mirror::Class*> expected_megamorphic;
+    TypeReferenceSet expected_megamorphic;
     AssertInlineCaches(inline_megamorphic,
                        expected_megamorphic,
                        info,
@@ -967,7 +973,7 @@
                                                        "LTestInline;",
                                                        "inlineMissingTypes");
     ASSERT_TRUE(inline_missing_types != nullptr);
-    std::set<mirror::Class*> expected_missing_Types;
+    TypeReferenceSet expected_missing_Types;
     AssertInlineCaches(inline_missing_types,
                        expected_missing_Types,
                        info,
diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h
index 7a99d3d..25eb85d 100644
--- a/runtime/class_linker-inl.h
+++ b/runtime/class_linker-inl.h
@@ -33,8 +33,8 @@
 
 namespace art {
 
-inline mirror::Class* ClassLinker::FindArrayClass(Thread* self,
-                                                  ObjPtr<mirror::Class>* element_class) {
+inline ObjPtr<mirror::Class> ClassLinker::FindArrayClass(Thread* self,
+                                                         ObjPtr<mirror::Class>* element_class) {
   for (size_t i = 0; i < kFindArrayCacheSize; ++i) {
     // Read the cached array class once to avoid races with other threads setting it.
     ObjPtr<mirror::Class> array_class = find_array_class_cache_[i].Read();
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index d6ac3ba..b03237f 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2060,8 +2060,7 @@
         // Add 100 in case new classes get loaded when we are filling in the object array.
         class_table_size = NumZygoteClasses() + NumNonZygoteClasses() + 100;
       }
-      ObjPtr<mirror::Class> class_type = mirror::Class::GetJavaLangClass();
-      ObjPtr<mirror::Class> array_of_class = FindArrayClass(self, &class_type);
+      ObjPtr<mirror::Class> array_of_class = GetClassRoot<mirror::ObjectArray<mirror::Class>>(this);
       classes.Assign(
           mirror::ObjectArray<mirror::Class>::Alloc(self, array_of_class, class_table_size));
       CHECK(classes != nullptr);  // OOME.
@@ -2164,9 +2163,9 @@
   return dex_cache.Ptr();
 }
 
-mirror::Class* ClassLinker::AllocClass(Thread* self,
-                                       ObjPtr<mirror::Class> java_lang_Class,
-                                       uint32_t class_size) {
+ObjPtr<mirror::Class> ClassLinker::AllocClass(Thread* self,
+                                              ObjPtr<mirror::Class> java_lang_Class,
+                                              uint32_t class_size) {
   DCHECK_GE(class_size, sizeof(mirror::Class));
   gc::Heap* heap = Runtime::Current()->GetHeap();
   mirror::Class::InitializeClassVisitor visitor(class_size);
@@ -2180,7 +2179,7 @@
   return k->AsClass();
 }
 
-mirror::Class* ClassLinker::AllocClass(Thread* self, uint32_t class_size) {
+ObjPtr<mirror::Class> ClassLinker::AllocClass(Thread* self, uint32_t class_size) {
   return AllocClass(self, GetClassRoot<mirror::Class>(this), class_size);
 }
 
@@ -2191,9 +2190,9 @@
       self, GetClassRoot<mirror::ObjectArray<mirror::StackTraceElement>>(this), length);
 }
 
-mirror::Class* ClassLinker::EnsureResolved(Thread* self,
-                                           const char* descriptor,
-                                           ObjPtr<mirror::Class> klass) {
+ObjPtr<mirror::Class> ClassLinker::EnsureResolved(Thread* self,
+                                                  const char* descriptor,
+                                                  ObjPtr<mirror::Class> klass) {
   DCHECK(klass != nullptr);
   if (kIsDebugBuild) {
     StackHandleScope<1> hs(self);
@@ -2401,9 +2400,9 @@
   return ret;
 }
 
-mirror::Class* ClassLinker::FindClass(Thread* self,
-                                      const char* descriptor,
-                                      Handle<mirror::ClassLoader> class_loader) {
+ObjPtr<mirror::Class> ClassLinker::FindClass(Thread* self,
+                                             const char* descriptor,
+                                             Handle<mirror::ClassLoader> class_loader) {
   DCHECK_NE(*descriptor, '\0') << "descriptor is empty string";
   DCHECK(self != nullptr);
   self->AssertNoPendingException();
@@ -2572,12 +2571,12 @@
   return result_ptr.Ptr();
 }
 
-mirror::Class* ClassLinker::DefineClass(Thread* self,
-                                        const char* descriptor,
-                                        size_t hash,
-                                        Handle<mirror::ClassLoader> class_loader,
-                                        const DexFile& dex_file,
-                                        const DexFile::ClassDef& dex_class_def) {
+ObjPtr<mirror::Class> ClassLinker::DefineClass(Thread* self,
+                                               const char* descriptor,
+                                               size_t hash,
+                                               Handle<mirror::ClassLoader> class_loader,
+                                               const DexFile& dex_file,
+                                               const DexFile::ClassDef& dex_class_def) {
   StackHandleScope<3> hs(self);
   auto klass = hs.NewHandle<mirror::Class>(nullptr);
 
@@ -3521,7 +3520,7 @@
   return DexCacheData();
 }
 
-mirror::Class* ClassLinker::CreatePrimitiveClass(Thread* self, Primitive::Type type) {
+ObjPtr<mirror::Class> ClassLinker::CreatePrimitiveClass(Thread* self, Primitive::Type type) {
   ObjPtr<mirror::Class> primitive_class =
       AllocClass(self, mirror::Class::PrimitiveClassSize(image_pointer_size_));
   if (UNLIKELY(primitive_class == nullptr)) {
@@ -3557,8 +3556,10 @@
 // array class; that always comes from the base element class.
 //
 // Returns null with an exception raised on failure.
-mirror::Class* ClassLinker::CreateArrayClass(Thread* self, const char* descriptor, size_t hash,
-                                             Handle<mirror::ClassLoader> class_loader) {
+ObjPtr<mirror::Class> ClassLinker::CreateArrayClass(Thread* self,
+                                                    const char* descriptor,
+                                                    size_t hash,
+                                                    Handle<mirror::ClassLoader> class_loader) {
   // Identify the underlying component type
   CHECK_EQ('[', descriptor[0]);
   StackHandleScope<2> hs(self);
@@ -3705,27 +3706,27 @@
   return existing.Ptr();
 }
 
-mirror::Class* ClassLinker::FindPrimitiveClass(char type) {
+ObjPtr<mirror::Class> ClassLinker::FindPrimitiveClass(char type) {
   ObjPtr<mirror::ObjectArray<mirror::Class>> class_roots = GetClassRoots();
   switch (type) {
     case 'B':
-      return GetClassRoot(ClassRoot::kPrimitiveByte, class_roots).Ptr();
+      return GetClassRoot(ClassRoot::kPrimitiveByte, class_roots);
     case 'C':
-      return GetClassRoot(ClassRoot::kPrimitiveChar, class_roots).Ptr();
+      return GetClassRoot(ClassRoot::kPrimitiveChar, class_roots);
     case 'D':
-      return GetClassRoot(ClassRoot::kPrimitiveDouble, class_roots).Ptr();
+      return GetClassRoot(ClassRoot::kPrimitiveDouble, class_roots);
     case 'F':
-      return GetClassRoot(ClassRoot::kPrimitiveFloat, class_roots).Ptr();
+      return GetClassRoot(ClassRoot::kPrimitiveFloat, class_roots);
     case 'I':
-      return GetClassRoot(ClassRoot::kPrimitiveInt, class_roots).Ptr();
+      return GetClassRoot(ClassRoot::kPrimitiveInt, class_roots);
     case 'J':
-      return GetClassRoot(ClassRoot::kPrimitiveLong, class_roots).Ptr();
+      return GetClassRoot(ClassRoot::kPrimitiveLong, class_roots);
     case 'S':
-      return GetClassRoot(ClassRoot::kPrimitiveShort, class_roots).Ptr();
+      return GetClassRoot(ClassRoot::kPrimitiveShort, class_roots);
     case 'Z':
-      return GetClassRoot(ClassRoot::kPrimitiveBoolean, class_roots).Ptr();
+      return GetClassRoot(ClassRoot::kPrimitiveBoolean, class_roots);
     case 'V':
-      return GetClassRoot(ClassRoot::kPrimitiveVoid, class_roots).Ptr();
+      return GetClassRoot(ClassRoot::kPrimitiveVoid, class_roots);
     default:
       break;
   }
@@ -3734,7 +3735,9 @@
   return nullptr;
 }
 
-mirror::Class* ClassLinker::InsertClass(const char* descriptor, ObjPtr<mirror::Class> klass, size_t hash) {
+ObjPtr<mirror::Class> ClassLinker::InsertClass(const char* descriptor,
+                                               ObjPtr<mirror::Class> klass,
+                                               size_t hash) {
   if (VLOG_IS_ON(class_linker)) {
     ObjPtr<mirror::DexCache> dex_cache = klass->GetDexCache();
     std::string source;
@@ -3789,16 +3792,16 @@
   Runtime::Current()->GetHeap()->WriteBarrierEveryFieldOf(klass);
 }
 
-mirror::Class* ClassLinker::LookupClass(Thread* self,
-                           const char* descriptor,
-                           ObjPtr<mirror::ClassLoader> class_loader) {
+ObjPtr<mirror::Class> ClassLinker::LookupClass(Thread* self,
+                                               const char* descriptor,
+                                               ObjPtr<mirror::ClassLoader> class_loader) {
   return LookupClass(self, descriptor, ComputeModifiedUtf8Hash(descriptor), class_loader);
 }
 
-mirror::Class* ClassLinker::LookupClass(Thread* self,
-                                        const char* descriptor,
-                                        size_t hash,
-                                        ObjPtr<mirror::ClassLoader> class_loader) {
+ObjPtr<mirror::Class> ClassLinker::LookupClass(Thread* self,
+                                               const char* descriptor,
+                                               size_t hash,
+                                               ObjPtr<mirror::ClassLoader> class_loader) {
   ReaderMutexLock mu(self, *Locks::classlinker_classes_lock_);
   ClassTable* const class_table = ClassTableForClassLoader(class_loader);
   if (class_table != nullptr) {
@@ -4251,12 +4254,12 @@
   }
 }
 
-mirror::Class* ClassLinker::CreateProxyClass(ScopedObjectAccessAlreadyRunnable& soa,
-                                             jstring name,
-                                             jobjectArray interfaces,
-                                             jobject loader,
-                                             jobjectArray methods,
-                                             jobjectArray throws) {
+ObjPtr<mirror::Class> ClassLinker::CreateProxyClass(ScopedObjectAccessAlreadyRunnable& soa,
+                                                    jstring name,
+                                                    jobjectArray interfaces,
+                                                    jobject loader,
+                                                    jobjectArray methods,
+                                                    jobjectArray throws) {
   Thread* self = soa.Self();
   StackHandleScope<10> hs(self);
   MutableHandle<mirror::Class> temp_klass(hs.NewHandle(
@@ -8104,8 +8107,7 @@
   // other than by looking at the shorty ?
   const size_t num_method_args = strlen(dex_file.StringDataByIdx(proto_id.shorty_idx_)) - 1;
 
-  ObjPtr<mirror::Class> class_type = mirror::Class::GetJavaLangClass();
-  ObjPtr<mirror::Class> array_of_class = FindArrayClass(self, &class_type);
+  ObjPtr<mirror::Class> array_of_class = GetClassRoot<mirror::ObjectArray<mirror::Class>>(this);
   Handle<mirror::ObjectArray<mirror::Class>> method_params(hs.NewHandle(
       mirror::ObjectArray<mirror::Class>::Alloc(self, array_of_class, num_method_args)));
   if (method_params == nullptr) {
@@ -8211,11 +8213,10 @@
   }
 
   StackHandleScope<4> hs(self);
-  ObjPtr<mirror::Class> class_type = mirror::Class::GetJavaLangClass();
-  ObjPtr<mirror::Class> array_of_class = FindArrayClass(self, &class_type);
+  ObjPtr<mirror::Class> array_of_class = GetClassRoot<mirror::ObjectArray<mirror::Class>>(this);
   Handle<mirror::ObjectArray<mirror::Class>> method_params(hs.NewHandle(
       mirror::ObjectArray<mirror::Class>::Alloc(self, array_of_class, num_params)));
-  if (UNLIKELY(method_params.Get() == nullptr)) {
+  if (UNLIKELY(method_params == nullptr)) {
     DCHECK(self->IsExceptionPending());
     return nullptr;
   }
@@ -8390,8 +8391,7 @@
   int32_t num_params = static_cast<int32_t>(shorty_length + receiver_count - 1);
 
   StackHandleScope<7> hs(self);
-  ObjPtr<mirror::Class> class_type = mirror::Class::GetJavaLangClass();
-  ObjPtr<mirror::Class> array_of_class = FindArrayClass(self, &class_type);
+  ObjPtr<mirror::Class> array_of_class = GetClassRoot<mirror::ObjectArray<mirror::Class>>(this);
   Handle<mirror::ObjectArray<mirror::Class>> method_params(hs.NewHandle(
       mirror::ObjectArray<mirror::Class>::Alloc(self, array_of_class, num_params)));
   if (method_params.Get() == nullptr) {
@@ -8889,19 +8889,19 @@
   const PointerSize pointer_size_;
 };
 
-mirror::Class* ClassLinker::GetHoldingClassOfCopiedMethod(ArtMethod* method) {
+ObjPtr<mirror::Class> ClassLinker::GetHoldingClassOfCopiedMethod(ArtMethod* method) {
   ScopedTrace trace(__FUNCTION__);  // Since this function is slow, have a trace to notify people.
   CHECK(method->IsCopied());
   FindVirtualMethodHolderVisitor visitor(method, image_pointer_size_);
   VisitClasses(&visitor);
-  return visitor.holder_.Ptr();
+  return visitor.holder_;
 }
 
-mirror::IfTable* ClassLinker::AllocIfTable(Thread* self, size_t ifcount) {
-  return down_cast<mirror::IfTable*>(
+ObjPtr<mirror::IfTable> ClassLinker::AllocIfTable(Thread* self, size_t ifcount) {
+  return ObjPtr<mirror::IfTable>::DownCast(ObjPtr<mirror::ObjectArray<mirror::Object>>(
       mirror::IfTable::Alloc(self,
                              GetClassRoot<mirror::ObjectArray<mirror::Object>>(this),
-                             ifcount * mirror::IfTable::kMax));
+                             ifcount * mirror::IfTable::kMax)));
 }
 
 // Instantiate ResolveMethod.
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 1912d21..e144144 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -147,22 +147,22 @@
 
   // Finds a class by its descriptor, loading it if necessary.
   // If class_loader is null, searches boot_class_path_.
-  mirror::Class* FindClass(Thread* self,
-                           const char* descriptor,
-                           Handle<mirror::ClassLoader> class_loader)
+  ObjPtr<mirror::Class> FindClass(Thread* self,
+                                  const char* descriptor,
+                                  Handle<mirror::ClassLoader> class_loader)
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Locks::dex_lock_);
 
   // Finds a class by its descriptor using the "system" class loader, ie by searching the
   // boot_class_path_.
-  mirror::Class* FindSystemClass(Thread* self, const char* descriptor)
+  ObjPtr<mirror::Class> FindSystemClass(Thread* self, const char* descriptor)
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Locks::dex_lock_) {
     return FindClass(self, descriptor, ScopedNullHandle<mirror::ClassLoader>());
   }
 
   // Finds the array class given for the element class.
-  mirror::Class* FindArrayClass(Thread* self, ObjPtr<mirror::Class>* element_class)
+  ObjPtr<mirror::Class> FindArrayClass(Thread* self, ObjPtr<mirror::Class>* element_class)
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Locks::dex_lock_);
 
@@ -172,20 +172,20 @@
   }
 
   // Define a new a class based on a ClassDef from a DexFile
-  mirror::Class* DefineClass(Thread* self,
-                             const char* descriptor,
-                             size_t hash,
-                             Handle<mirror::ClassLoader> class_loader,
-                             const DexFile& dex_file,
-                             const DexFile::ClassDef& dex_class_def)
+  ObjPtr<mirror::Class> DefineClass(Thread* self,
+                                    const char* descriptor,
+                                    size_t hash,
+                                    Handle<mirror::ClassLoader> class_loader,
+                                    const DexFile& dex_file,
+                                    const DexFile::ClassDef& dex_class_def)
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Locks::dex_lock_);
 
   // Finds a class by its descriptor, returning null if it isn't wasn't loaded
   // by the given 'class_loader'.
-  mirror::Class* LookupClass(Thread* self,
-                             const char* descriptor,
-                             ObjPtr<mirror::ClassLoader> class_loader)
+  ObjPtr<mirror::Class> LookupClass(Thread* self,
+                                    const char* descriptor,
+                                    ObjPtr<mirror::ClassLoader> class_loader)
       REQUIRES(!Locks::classlinker_classes_lock_)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
@@ -194,7 +194,7 @@
       REQUIRES(!Locks::classlinker_classes_lock_)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  mirror::Class* FindPrimitiveClass(char type) REQUIRES_SHARED(Locks::mutator_lock_);
+  ObjPtr<mirror::Class> FindPrimitiveClass(char type) REQUIRES_SHARED(Locks::mutator_lock_);
 
   void DumpForSigQuit(std::ostream& os) REQUIRES(!Locks::classlinker_classes_lock_);
 
@@ -457,7 +457,7 @@
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Roles::uninterruptible_);
 
-  mirror::IfTable* AllocIfTable(Thread* self, size_t ifcount)
+  ObjPtr<mirror::IfTable> AllocIfTable(Thread* self, size_t ifcount)
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Roles::uninterruptible_);
 
@@ -484,12 +484,12 @@
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Locks::dex_lock_);
 
-  mirror::Class* CreateProxyClass(ScopedObjectAccessAlreadyRunnable& soa,
-                                  jstring name,
-                                  jobjectArray interfaces,
-                                  jobject loader,
-                                  jobjectArray methods,
-                                  jobjectArray throws)
+  ObjPtr<mirror::Class> CreateProxyClass(ScopedObjectAccessAlreadyRunnable& soa,
+                                         jstring name,
+                                         jobjectArray interfaces,
+                                         jobject loader,
+                                         jobjectArray methods,
+                                         jobjectArray throws)
       REQUIRES_SHARED(Locks::mutator_lock_);
   std::string GetDescriptorForProxy(ObjPtr<mirror::Class> proxy_class)
       REQUIRES_SHARED(Locks::mutator_lock_);
@@ -532,7 +532,9 @@
   // Attempts to insert a class into a class table.  Returns null if
   // the class was inserted, otherwise returns an existing class with
   // the same descriptor and ClassLoader.
-  mirror::Class* InsertClass(const char* descriptor, ObjPtr<mirror::Class> klass, size_t hash)
+  ObjPtr<mirror::Class> InsertClass(const char* descriptor,
+                                    ObjPtr<mirror::Class> klass,
+                                    size_t hash)
       REQUIRES(!Locks::classlinker_classes_lock_)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
@@ -660,7 +662,7 @@
       REQUIRES(!Locks::dex_lock_);
 
   // Get the actual holding class for a copied method. Pretty slow, don't call often.
-  mirror::Class* GetHoldingClassOfCopiedMethod(ArtMethod* method)
+  ObjPtr<mirror::Class> GetHoldingClassOfCopiedMethod(ArtMethod* method)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
   // Returns null if not found.
@@ -764,16 +766,16 @@
       REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
 
   // For early bootstrapping by Init
-  mirror::Class* AllocClass(Thread* self,
-                            ObjPtr<mirror::Class> java_lang_Class,
-                            uint32_t class_size)
+  ObjPtr<mirror::Class> AllocClass(Thread* self,
+                                   ObjPtr<mirror::Class> java_lang_Class,
+                                   uint32_t class_size)
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Roles::uninterruptible_);
 
-  // Alloc* convenience functions to avoid needing to pass in mirror::Class*
-  // values that are known to the ClassLinker such as
-  // kObjectArrayClass and kJavaLangString etc.
-  mirror::Class* AllocClass(Thread* self, uint32_t class_size)
+  // Alloc* convenience functions to avoid needing to pass in ObjPtr<mirror::Class>
+  // values that are known to the ClassLinker such as classes corresponding to
+  // ClassRoot::kObjectArrayClass and ClassRoot::kJavaLangString etc.
+  ObjPtr<mirror::Class> AllocClass(Thread* self, uint32_t class_size)
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Roles::uninterruptible_);
 
@@ -791,14 +793,14 @@
       REQUIRES(!Locks::dex_lock_)
       REQUIRES(!Roles::uninterruptible_);
 
-  mirror::Class* CreatePrimitiveClass(Thread* self, Primitive::Type type)
+  ObjPtr<mirror::Class> CreatePrimitiveClass(Thread* self, Primitive::Type type)
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Roles::uninterruptible_);
 
-  mirror::Class* CreateArrayClass(Thread* self,
-                                  const char* descriptor,
-                                  size_t hash,
-                                  Handle<mirror::ClassLoader> class_loader)
+  ObjPtr<mirror::Class> CreateArrayClass(Thread* self,
+                                         const char* descriptor,
+                                         size_t hash,
+                                         Handle<mirror::ClassLoader> class_loader)
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
 
@@ -886,10 +888,10 @@
 
   // Finds a class by its descriptor, returning NULL if it isn't wasn't loaded
   // by the given 'class_loader'. Uses the provided hash for the descriptor.
-  mirror::Class* LookupClass(Thread* self,
-                             const char* descriptor,
-                             size_t hash,
-                             ObjPtr<mirror::ClassLoader> class_loader)
+  ObjPtr<mirror::Class> LookupClass(Thread* self,
+                                    const char* descriptor,
+                                    size_t hash,
+                                    ObjPtr<mirror::ClassLoader> class_loader)
       REQUIRES(!Locks::classlinker_classes_lock_)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
@@ -1160,7 +1162,9 @@
   // when resolution has occurred. This happens in mirror::Class::SetStatus. As resolution may
   // retire a class, the version of the class in the table is returned and this may differ from
   // the class passed in.
-  mirror::Class* EnsureResolved(Thread* self, const char* descriptor, ObjPtr<mirror::Class> klass)
+  ObjPtr<mirror::Class> EnsureResolved(Thread* self,
+                                       const char* descriptor,
+                                       ObjPtr<mirror::Class> klass)
       WARN_UNUSED
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Locks::dex_lock_);
diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc
index 48ec6b6..5d420aa 100644
--- a/runtime/class_linker_test.cc
+++ b/runtime/class_linker_test.cc
@@ -198,7 +198,8 @@
     ASSERT_STREQ(array_descriptor.c_str(), array->GetDescriptor(&temp));
     EXPECT_TRUE(array->GetSuperClass() != nullptr);
     Thread* self = Thread::Current();
-    EXPECT_EQ(class_linker_->FindSystemClass(self, "Ljava/lang/Object;"), array->GetSuperClass());
+    EXPECT_OBJ_PTR_EQ(class_linker_->FindSystemClass(self, "Ljava/lang/Object;"),
+                      array->GetSuperClass());
     EXPECT_TRUE(array->HasSuperClass());
     ASSERT_TRUE(array->GetComponentType() != nullptr);
     ASSERT_GT(strlen(array->GetComponentType()->GetDescriptor(&temp)), 0U);
@@ -1079,27 +1080,27 @@
   ScopedObjectAccess soa(Thread::Current());
   StackHandleScope<5> hs(soa.Self());
   Handle<mirror::LongArray> long_array(hs.NewHandle(mirror::LongArray::Alloc(soa.Self(), 0)));
-  EXPECT_EQ(class_linker_->FindSystemClass(soa.Self(), "[J"), long_array->GetClass());
+  EXPECT_OBJ_PTR_EQ(class_linker_->FindSystemClass(soa.Self(), "[J"), long_array->GetClass());
   uintptr_t data_offset = reinterpret_cast<uintptr_t>(long_array->GetData());
   EXPECT_TRUE(IsAligned<8>(data_offset));  // Longs require 8 byte alignment
 
   Handle<mirror::DoubleArray> double_array(hs.NewHandle(mirror::DoubleArray::Alloc(soa.Self(), 0)));
-  EXPECT_EQ(class_linker_->FindSystemClass(soa.Self(), "[D"), double_array->GetClass());
+  EXPECT_OBJ_PTR_EQ(class_linker_->FindSystemClass(soa.Self(), "[D"), double_array->GetClass());
   data_offset = reinterpret_cast<uintptr_t>(double_array->GetData());
   EXPECT_TRUE(IsAligned<8>(data_offset));  // Doubles require 8 byte alignment
 
   Handle<mirror::IntArray> int_array(hs.NewHandle(mirror::IntArray::Alloc(soa.Self(), 0)));
-  EXPECT_EQ(class_linker_->FindSystemClass(soa.Self(), "[I"), int_array->GetClass());
+  EXPECT_OBJ_PTR_EQ(class_linker_->FindSystemClass(soa.Self(), "[I"), int_array->GetClass());
   data_offset = reinterpret_cast<uintptr_t>(int_array->GetData());
   EXPECT_TRUE(IsAligned<4>(data_offset));  // Ints require 4 byte alignment
 
   Handle<mirror::CharArray> char_array(hs.NewHandle(mirror::CharArray::Alloc(soa.Self(), 0)));
-  EXPECT_EQ(class_linker_->FindSystemClass(soa.Self(), "[C"), char_array->GetClass());
+  EXPECT_OBJ_PTR_EQ(class_linker_->FindSystemClass(soa.Self(), "[C"), char_array->GetClass());
   data_offset = reinterpret_cast<uintptr_t>(char_array->GetData());
   EXPECT_TRUE(IsAligned<2>(data_offset));  // Chars require 2 byte alignment
 
   Handle<mirror::ShortArray> short_array(hs.NewHandle(mirror::ShortArray::Alloc(soa.Self(), 0)));
-  EXPECT_EQ(class_linker_->FindSystemClass(soa.Self(), "[S"), short_array->GetClass());
+  EXPECT_OBJ_PTR_EQ(class_linker_->FindSystemClass(soa.Self(), "[S"), short_array->GetClass());
   data_offset = reinterpret_cast<uintptr_t>(short_array->GetData());
   EXPECT_TRUE(IsAligned<2>(data_offset));  // Shorts require 2 byte alignment
 
diff --git a/runtime/gc/space/space_test.h b/runtime/gc/space/space_test.h
index d5861ed..c94b666 100644
--- a/runtime/gc/space/space_test.h
+++ b/runtime/gc/space/space_test.h
@@ -53,13 +53,11 @@
   }
 
   mirror::Class* GetByteArrayClass(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) {
-    StackHandleScope<1> hs(self);
-    auto null_loader(hs.NewHandle<mirror::ClassLoader>(nullptr));
     if (byte_array_class_ == nullptr) {
-      mirror::Class* byte_array_class =
-          Runtime::Current()->GetClassLinker()->FindClass(self, "[B", null_loader);
+      ObjPtr<mirror::Class> byte_array_class =
+          Runtime::Current()->GetClassLinker()->FindSystemClass(self, "[B");
       EXPECT_TRUE(byte_array_class != nullptr);
-      byte_array_class_ = self->GetJniEnv()->NewLocalRef(byte_array_class);
+      byte_array_class_ = self->GetJniEnv()->NewLocalRef(byte_array_class.Ptr());
       EXPECT_TRUE(byte_array_class_ != nullptr);
     }
     return self->DecodeJObject(byte_array_class_)->AsClass();
diff --git a/runtime/hidden_api_test.cc b/runtime/hidden_api_test.cc
index ab0c290..a41d284 100644
--- a/runtime/hidden_api_test.cc
+++ b/runtime/hidden_api_test.cc
@@ -325,8 +325,8 @@
   ASSERT_TRUE(h_iface != nullptr);
 
   // Create the proxy class.
-  std::vector<mirror::Class*> interfaces;
-  interfaces.push_back(h_iface.Get());
+  std::vector<Handle<mirror::Class>> interfaces;
+  interfaces.push_back(h_iface);
   Handle<mirror::Class> proxyClass = hs.NewHandle(proxy_test::GenerateProxyClass(
       soa, jclass_loader_, runtime_->GetClassLinker(), "$Proxy1234", interfaces));
   ASSERT_TRUE(proxyClass != nullptr);
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index fab3509..56658c3 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -1128,9 +1128,9 @@
 
   StackHandleScope<2> hs(self);
   // Create array for parameter types.
-  ObjPtr<mirror::Class> class_type = mirror::Class::GetJavaLangClass();
   ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
-  ObjPtr<mirror::Class> class_array_type = class_linker->FindArrayClass(self, &class_type);
+  ObjPtr<mirror::Class> class_array_type =
+      GetClassRoot<mirror::ObjectArray<mirror::Class>>(class_linker);
   Handle<mirror::ObjectArray<mirror::Class>> ptypes = hs.NewHandle(
       mirror::ObjectArray<mirror::Class>::Alloc(self,
                                                 class_array_type,
diff --git a/runtime/interpreter/unstarted_runtime_test.cc b/runtime/interpreter/unstarted_runtime_test.cc
index 88cfafb..fee8375 100644
--- a/runtime/interpreter/unstarted_runtime_test.cc
+++ b/runtime/interpreter/unstarted_runtime_test.cc
@@ -196,7 +196,7 @@
   // Prepare for aborts. Aborts assume that the exception class is already resolved, as the
   // loading code doesn't work under transactions.
   void PrepareForAborts() REQUIRES_SHARED(Locks::mutator_lock_) {
-    mirror::Object* result = Runtime::Current()->GetClassLinker()->FindClass(
+    ObjPtr<mirror::Object> result = Runtime::Current()->GetClassLinker()->FindClass(
         Thread::Current(),
         Transaction::kAbortExceptionSignature,
         ScopedNullHandle<mirror::ClassLoader>());
diff --git a/runtime/method_handles_test.cc b/runtime/method_handles_test.cc
index a947342..0db9551 100644
--- a/runtime/method_handles_test.cc
+++ b/runtime/method_handles_test.cc
@@ -17,6 +17,7 @@
 #include "method_handles.h"
 
 #include "class_linker-inl.h"
+#include "class_root.h"
 #include "common_runtime_test.h"
 #include "handle_scope-inl.h"
 #include "jvalue-inl.h"
@@ -49,12 +50,11 @@
         REQUIRES_SHARED(Locks::mutator_lock_) {
     ClassLinker* cl = Runtime::Current()->GetClassLinker();
     StackHandleScope<2> hs(self);
-    ObjPtr<mirror::Class> class_type = mirror::Class::GetJavaLangClass();
-    ObjPtr<mirror::Class> class_array_type = cl->FindArrayClass(self, &class_type);
+    ObjPtr<mirror::Class> class_array_type = GetClassRoot<mirror::ObjectArray<mirror::Class>>(cl);
     auto parameter_types = hs.NewHandle(
         mirror::ObjectArray<mirror::Class>::Alloc(self, class_array_type, 1));
     parameter_types->Set(0, parameter_type.Get());
-    Handle<mirror::Class> void_class = hs.NewHandle(cl->FindPrimitiveClass('V'));
+    Handle<mirror::Class> void_class = hs.NewHandle(GetClassRoot(ClassRoot::kPrimitiveVoid, cl));
     return mirror::MethodType::Create(self, void_class, parameter_types);
   }
 
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index ab50973..5328ad9 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -145,6 +145,7 @@
                                        GetDirectMethodsStartOffset(),
                                        GetCopiedMethodsStartOffset());
 }
+
 template<VerifyObjectFlags kVerifyFlags>
 inline ArraySlice<ArtMethod> Class::GetDeclaredVirtualMethodsSlice(PointerSize pointer_size) {
   DCHECK(IsLoaded() || IsErroneous());
@@ -281,8 +282,7 @@
   return &GetVirtualMethodsSliceUnchecked(pointer_size)[i];
 }
 
-template<VerifyObjectFlags kVerifyFlags,
-         ReadBarrierOption kReadBarrierOption>
+template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption>
 inline PointerArray* Class::GetVTable() {
   DCHECK(IsLoaded<kVerifyFlags>() || IsErroneous<kVerifyFlags>());
   return GetFieldObject<PointerArray, kVerifyFlags, kReadBarrierOption>(
@@ -302,8 +302,7 @@
   return GetVTable() != nullptr || ShouldHaveEmbeddedVTable();
 }
 
-  template<VerifyObjectFlags kVerifyFlags,
-           ReadBarrierOption kReadBarrierOption>
+template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption>
 inline int32_t Class::GetVTableLength() {
   if (ShouldHaveEmbeddedVTable<kVerifyFlags, kReadBarrierOption>()) {
     return GetEmbeddedVTableLength();
@@ -312,15 +311,15 @@
       GetVTable<kVerifyFlags, kReadBarrierOption>()->GetLength() : 0;
 }
 
-  template<VerifyObjectFlags kVerifyFlags,
-           ReadBarrierOption kReadBarrierOption>
+template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption>
 inline ArtMethod* Class::GetVTableEntry(uint32_t i, PointerSize pointer_size) {
   if (ShouldHaveEmbeddedVTable<kVerifyFlags, kReadBarrierOption>()) {
     return GetEmbeddedVTableEntry(i, pointer_size);
   }
   auto* vtable = GetVTable<kVerifyFlags, kReadBarrierOption>();
   DCHECK(vtable != nullptr);
-  return vtable->template GetElementPtrSize<ArtMethod*, kVerifyFlags, kReadBarrierOption>(i, pointer_size);
+  return vtable->template GetElementPtrSize<ArtMethod*, kVerifyFlags, kReadBarrierOption>(
+      i, pointer_size);
 }
 
 inline int32_t Class::GetEmbeddedVTableLength() {
@@ -410,7 +409,7 @@
 //   Object[]         = int[] --> false
 //
 inline bool Class::IsArrayAssignableFromArray(ObjPtr<Class> src) {
-  DCHECK(IsArrayClass())  << PrettyClass();
+  DCHECK(IsArrayClass()) << PrettyClass();
   DCHECK(src->IsArrayClass()) << src->PrettyClass();
   return GetComponentType()->IsAssignableFrom(src->GetComponentType());
 }
@@ -622,16 +621,14 @@
   return FindVirtualMethodForVirtual(method, pointer_size);
 }
 
-template<VerifyObjectFlags kVerifyFlags,
-         ReadBarrierOption kReadBarrierOption>
+template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption>
 inline IfTable* Class::GetIfTable() {
   ObjPtr<IfTable> ret = GetFieldObject<IfTable, kVerifyFlags, kReadBarrierOption>(IfTableOffset());
   DCHECK(ret != nullptr) << PrettyClass(this);
   return ret.Ptr();
 }
 
-template<VerifyObjectFlags kVerifyFlags,
-         ReadBarrierOption kReadBarrierOption>
+template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption>
 inline int32_t Class::GetIfTableCount() {
   return GetIfTable<kVerifyFlags, kReadBarrierOption>()->Count();
 }
@@ -734,7 +731,7 @@
 }
 
 inline void Class::SetName(ObjPtr<String> name) {
-    SetFieldObjectTransaction(OFFSET_OF_OBJECT_MEMBER(Class, name_), name);
+  SetFieldObjectTransaction(OFFSET_OF_OBJECT_MEMBER(Class, name_), name);
 }
 
 template<VerifyObjectFlags kVerifyFlags>
@@ -887,8 +884,8 @@
 inline void Class::AssertInitializedOrInitializingInThread(Thread* self) {
   if (kIsDebugBuild && !IsInitialized()) {
     CHECK(IsInitializing()) << PrettyClass() << " is not initializing: " << GetStatus();
-    CHECK_EQ(GetClinitThreadId(), self->GetTid()) << PrettyClass()
-                                                  << " is initializing in a different thread";
+    CHECK_EQ(GetClinitThreadId(), self->GetTid())
+        << PrettyClass() << " is initializing in a different thread";
   }
 }
 
@@ -964,18 +961,15 @@
   return GetDirectMethodsSliceUnchecked(pointer_size);
 }
 
-inline ArraySlice<ArtMethod> Class::GetDeclaredMethods(
-      PointerSize pointer_size) {
+inline ArraySlice<ArtMethod> Class::GetDeclaredMethods(PointerSize pointer_size) {
   return GetDeclaredMethodsSliceUnchecked(pointer_size);
 }
 
-inline ArraySlice<ArtMethod> Class::GetDeclaredVirtualMethods(
-      PointerSize pointer_size) {
+inline ArraySlice<ArtMethod> Class::GetDeclaredVirtualMethods(PointerSize pointer_size) {
   return GetDeclaredVirtualMethodsSliceUnchecked(pointer_size);
 }
 
-inline ArraySlice<ArtMethod> Class::GetVirtualMethods(
-    PointerSize pointer_size) {
+inline ArraySlice<ArtMethod> Class::GetVirtualMethods(PointerSize pointer_size) {
   CheckPointerSize(pointer_size);
   return GetVirtualMethodsSliceUnchecked(pointer_size);
 }
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index cb2708d..fea7764 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -1251,7 +1251,7 @@
 
 uint32_t Class::Depth() {
   uint32_t depth = 0;
-  for (ObjPtr<Class> klass = this; klass->GetSuperClass() != nullptr; klass = klass->GetSuperClass()) {
+  for (ObjPtr<Class> cls = this; cls->GetSuperClass() != nullptr; cls = cls->GetSuperClass()) {
     depth++;
   }
   return depth;
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index 7d5f539..cf2d5a4 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -933,12 +933,10 @@
   ArtMethod* FindConstructor(const StringPiece& signature, PointerSize pointer_size)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  ArtMethod* FindDeclaredVirtualMethodByName(const StringPiece& name,
-                                             PointerSize pointer_size)
+  ArtMethod* FindDeclaredVirtualMethodByName(const StringPiece& name, PointerSize pointer_size)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  ArtMethod* FindDeclaredDirectMethodByName(const StringPiece& name,
-                                            PointerSize pointer_size)
+  ArtMethod* FindDeclaredDirectMethodByName(const StringPiece& name, PointerSize pointer_size)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
   ArtMethod* FindClassInitializer(PointerSize pointer_size) REQUIRES_SHARED(Locks::mutator_lock_);
@@ -1197,10 +1195,7 @@
   void AssertInitializedOrInitializingInThread(Thread* self)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  Class* CopyOf(Thread* self,
-                int32_t new_length,
-                ImTable* imt,
-                PointerSize pointer_size)
+  Class* CopyOf(Thread* self, int32_t new_length, ImTable* imt, PointerSize pointer_size)
       REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
 
   // For proxy class only.
diff --git a/runtime/mirror/method_type.cc b/runtime/mirror/method_type.cc
index a8be8b7..483fff5 100644
--- a/runtime/mirror/method_type.cc
+++ b/runtime/mirror/method_type.cc
@@ -28,9 +28,7 @@
 
 ObjPtr<ObjectArray<Class>> AllocatePTypesArray(Thread* self, int count)
     REQUIRES_SHARED(Locks::mutator_lock_) {
-  ObjPtr<Class> class_type = Class::GetJavaLangClass();
-  ObjPtr<Class> class_array_type =
-      Runtime::Current()->GetClassLinker()->FindArrayClass(self, &class_type);
+  ObjPtr<Class> class_array_type = GetClassRoot<mirror::ObjectArray<mirror::Class>>();
   return ObjectArray<Class>::Alloc(self, class_array_type, count);
 }
 
diff --git a/runtime/mirror/method_type_test.cc b/runtime/mirror/method_type_test.cc
index 16bfc73..2bdea72 100644
--- a/runtime/mirror/method_type_test.cc
+++ b/runtime/mirror/method_type_test.cc
@@ -22,6 +22,7 @@
 #include "class-inl.h"
 #include "class_linker-inl.h"
 #include "class_loader.h"
+#include "class_root.h"
 #include "common_runtime_test.h"
 #include "handle_scope-inl.h"
 #include "object_array-inl.h"
@@ -53,8 +54,8 @@
           soa.Self(), FullyQualifiedType(return_type).c_str(), boot_class_loader));
   CHECK(return_clazz != nullptr);
 
-  ObjPtr<mirror::Class> class_type = mirror::Class::GetJavaLangClass();
-  ObjPtr<mirror::Class> class_array_type = class_linker->FindArrayClass(self, &class_type);
+  ObjPtr<mirror::Class> class_array_type =
+      GetClassRoot<mirror::ObjectArray<mirror::Class>>(class_linker);
   Handle<mirror::ObjectArray<mirror::Class>> param_classes = hs.NewHandle(
       mirror::ObjectArray<mirror::Class>::Alloc(self, class_array_type, param_types.size()));
 
diff --git a/runtime/mirror/object-inl.h b/runtime/mirror/object-inl.h
index bfebd5d..cd822c2 100644
--- a/runtime/mirror/object-inl.h
+++ b/runtime/mirror/object-inl.h
@@ -412,17 +412,21 @@
   return GetFieldByte<kVerifyFlags, true>(field_offset);
 }
 
-template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags,
-    bool kIsVolatile>
+template<bool kTransactionActive,
+         bool kCheckTransaction,
+         VerifyObjectFlags kVerifyFlags,
+         bool kIsVolatile>
 inline void Object::SetFieldBoolean(MemberOffset field_offset, uint8_t new_value)
     REQUIRES_SHARED(Locks::mutator_lock_) {
   if (kCheckTransaction) {
     DCHECK_EQ(kTransactionActive, Runtime::Current()->IsActiveTransaction());
   }
   if (kTransactionActive) {
-    Runtime::Current()->RecordWriteFieldBoolean(this, field_offset,
-                                           GetFieldBoolean<kVerifyFlags, kIsVolatile>(field_offset),
-                                           kIsVolatile);
+    Runtime::Current()->RecordWriteFieldBoolean(
+        this,
+        field_offset,
+        GetFieldBoolean<kVerifyFlags, kIsVolatile>(field_offset),
+        kIsVolatile);
   }
   if (kVerifyFlags & kVerifyThis) {
     VerifyObject(this);
@@ -430,17 +434,20 @@
   SetField<uint8_t, kIsVolatile>(field_offset, new_value);
 }
 
-template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags,
-    bool kIsVolatile>
+template<bool kTransactionActive,
+         bool kCheckTransaction,
+         VerifyObjectFlags kVerifyFlags,
+         bool kIsVolatile>
 inline void Object::SetFieldByte(MemberOffset field_offset, int8_t new_value)
     REQUIRES_SHARED(Locks::mutator_lock_) {
   if (kCheckTransaction) {
     DCHECK_EQ(kTransactionActive, Runtime::Current()->IsActiveTransaction());
   }
   if (kTransactionActive) {
-    Runtime::Current()->RecordWriteFieldByte(this, field_offset,
-                                           GetFieldByte<kVerifyFlags, kIsVolatile>(field_offset),
-                                           kIsVolatile);
+    Runtime::Current()->RecordWriteFieldByte(this,
+                                             field_offset,
+                                             GetFieldByte<kVerifyFlags, kIsVolatile>(field_offset),
+                                             kIsVolatile);
   }
   if (kVerifyFlags & kVerifyThis) {
     VerifyObject(this);
@@ -486,16 +493,19 @@
   return GetFieldShort<kVerifyFlags, true>(field_offset);
 }
 
-template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags,
-    bool kIsVolatile>
+template<bool kTransactionActive,
+         bool kCheckTransaction,
+         VerifyObjectFlags kVerifyFlags,
+         bool kIsVolatile>
 inline void Object::SetFieldChar(MemberOffset field_offset, uint16_t new_value) {
   if (kCheckTransaction) {
     DCHECK_EQ(kTransactionActive, Runtime::Current()->IsActiveTransaction());
   }
   if (kTransactionActive) {
-    Runtime::Current()->RecordWriteFieldChar(this, field_offset,
-                                           GetFieldChar<kVerifyFlags, kIsVolatile>(field_offset),
-                                           kIsVolatile);
+    Runtime::Current()->RecordWriteFieldChar(this,
+                                             field_offset,
+                                             GetFieldChar<kVerifyFlags, kIsVolatile>(field_offset),
+                                             kIsVolatile);
   }
   if (kVerifyFlags & kVerifyThis) {
     VerifyObject(this);
@@ -503,16 +513,19 @@
   SetField<uint16_t, kIsVolatile>(field_offset, new_value);
 }
 
-template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags,
-    bool kIsVolatile>
+template<bool kTransactionActive,
+         bool kCheckTransaction,
+         VerifyObjectFlags kVerifyFlags,
+         bool kIsVolatile>
 inline void Object::SetFieldShort(MemberOffset field_offset, int16_t new_value) {
   if (kCheckTransaction) {
     DCHECK_EQ(kTransactionActive, Runtime::Current()->IsActiveTransaction());
   }
   if (kTransactionActive) {
-    Runtime::Current()->RecordWriteFieldChar(this, field_offset,
-                                           GetFieldShort<kVerifyFlags, kIsVolatile>(field_offset),
-                                           kIsVolatile);
+    Runtime::Current()->RecordWriteFieldChar(this,
+                                             field_offset,
+                                             GetFieldShort<kVerifyFlags, kIsVolatile>(field_offset),
+                                             kIsVolatile);
   }
   if (kVerifyFlags & kVerifyThis) {
     VerifyObject(this);
@@ -532,14 +545,17 @@
       field_offset, new_value);
 }
 
-template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags,
-    bool kIsVolatile>
+template<bool kTransactionActive,
+         bool kCheckTransaction,
+         VerifyObjectFlags kVerifyFlags,
+         bool kIsVolatile>
 inline void Object::SetField32(MemberOffset field_offset, int32_t new_value) {
   if (kCheckTransaction) {
     DCHECK_EQ(kTransactionActive, Runtime::Current()->IsActiveTransaction());
   }
   if (kTransactionActive) {
-    Runtime::Current()->RecordWriteField32(this, field_offset,
+    Runtime::Current()->RecordWriteField32(this,
+                                           field_offset,
                                            GetField32<kVerifyFlags, kIsVolatile>(field_offset),
                                            kIsVolatile);
   }
@@ -567,7 +583,8 @@
 
 template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags>
 inline bool Object::CasFieldWeakSequentiallyConsistent32(MemberOffset field_offset,
-                                                         int32_t old_value, int32_t new_value) {
+                                                         int32_t old_value,
+                                                         int32_t new_value) {
   if (kCheckTransaction) {
     DCHECK_EQ(kTransactionActive, Runtime::Current()->IsActiveTransaction());
   }
@@ -585,7 +602,8 @@
 
 template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags>
 inline bool Object::CasFieldWeakAcquire32(MemberOffset field_offset,
-                                          int32_t old_value, int32_t new_value) {
+                                          int32_t old_value,
+                                          int32_t new_value) {
   if (kCheckTransaction) {
     DCHECK_EQ(kTransactionActive, Runtime::Current()->IsActiveTransaction());
   }
@@ -603,7 +621,8 @@
 
 template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags>
 inline bool Object::CasFieldWeakRelease32(MemberOffset field_offset,
-                                          int32_t old_value, int32_t new_value) {
+                                          int32_t old_value,
+                                          int32_t new_value) {
   if (kCheckTransaction) {
     DCHECK_EQ(kTransactionActive, Runtime::Current()->IsActiveTransaction());
   }
@@ -621,7 +640,8 @@
 
 template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags>
 inline bool Object::CasFieldStrongSequentiallyConsistent32(MemberOffset field_offset,
-                                                           int32_t old_value, int32_t new_value) {
+                                                           int32_t old_value,
+                                                           int32_t new_value) {
   if (kCheckTransaction) {
     DCHECK_EQ(kTransactionActive, Runtime::Current()->IsActiveTransaction());
   }
@@ -637,14 +657,17 @@
   return atomic_addr->CompareAndSetStrongSequentiallyConsistent(old_value, new_value);
 }
 
-template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags,
-    bool kIsVolatile>
+template<bool kTransactionActive,
+         bool kCheckTransaction,
+         VerifyObjectFlags kVerifyFlags,
+         bool kIsVolatile>
 inline void Object::SetField64(MemberOffset field_offset, int64_t new_value) {
   if (kCheckTransaction) {
     DCHECK_EQ(kTransactionActive, Runtime::Current()->IsActiveTransaction());
   }
   if (kTransactionActive) {
-    Runtime::Current()->RecordWriteField64(this, field_offset,
+    Runtime::Current()->RecordWriteField64(this,
+                                           field_offset,
                                            GetField64<kVerifyFlags, kIsVolatile>(field_offset),
                                            kIsVolatile);
   }
@@ -678,7 +701,8 @@
 
 template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags>
 inline bool Object::CasFieldWeakSequentiallyConsistent64(MemberOffset field_offset,
-                                                         int64_t old_value, int64_t new_value) {
+                                                         int64_t old_value,
+                                                         int64_t new_value) {
   if (kCheckTransaction) {
     DCHECK_EQ(kTransactionActive, Runtime::Current()->IsActiveTransaction());
   }
@@ -695,7 +719,8 @@
 
 template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags>
 inline bool Object::CasFieldStrongSequentiallyConsistent64(MemberOffset field_offset,
-                                                           int64_t old_value, int64_t new_value) {
+                                                           int64_t old_value,
+                                                           int64_t new_value) {
   if (kCheckTransaction) {
     DCHECK_EQ(kTransactionActive, Runtime::Current()->IsActiveTransaction());
   }
@@ -710,7 +735,9 @@
   return atomic_addr->CompareAndSetStrongSequentiallyConsistent(old_value, new_value);
 }
 
-template<class T, VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption,
+template<class T,
+         VerifyObjectFlags kVerifyFlags,
+         ReadBarrierOption kReadBarrierOption,
          bool kIsVolatile>
 inline T* Object::GetFieldObject(MemberOffset field_offset) {
   if (kVerifyFlags & kVerifyThis) {
@@ -733,8 +760,10 @@
   return GetFieldObject<T, kVerifyFlags, kReadBarrierOption, true>(field_offset);
 }
 
-template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags,
-    bool kIsVolatile>
+template<bool kTransactionActive,
+         bool kCheckTransaction,
+         VerifyObjectFlags kVerifyFlags,
+         bool kIsVolatile>
 inline void Object::SetFieldObjectWithoutWriteBarrier(MemberOffset field_offset,
                                                       ObjPtr<Object> new_value) {
   if (kCheckTransaction) {
@@ -760,8 +789,10 @@
   objref_addr->Assign<kIsVolatile>(new_value.Ptr());
 }
 
-template<bool kTransactionActive, bool kCheckTransaction, VerifyObjectFlags kVerifyFlags,
-    bool kIsVolatile>
+template<bool kTransactionActive,
+         bool kCheckTransaction,
+         VerifyObjectFlags kVerifyFlags,
+         bool kIsVolatile>
 inline void Object::SetFieldObject(MemberOffset field_offset, ObjPtr<Object> new_value) {
   SetFieldObjectWithoutWriteBarrier<kTransactionActive, kCheckTransaction, kVerifyFlags,
       kIsVolatile>(field_offset, new_value);
diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc
index 0e03e37..4240e70 100644
--- a/runtime/mirror/object.cc
+++ b/runtime/mirror/object.cc
@@ -271,7 +271,7 @@
     }
   }
   LOG(FATAL) << "Failed to find field for assignment to " << reinterpret_cast<void*>(this)
-      << " of type " << c->PrettyDescriptor() << " at offset " << field_offset;
+             << " of type " << c->PrettyDescriptor() << " at offset " << field_offset;
   UNREACHABLE();
 }
 
diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h
index 82045c7..8584b8a 100644
--- a/runtime/mirror/object.h
+++ b/runtime/mirror/object.h
@@ -282,13 +282,16 @@
   bool IsPhantomReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_);
 
   // Accessor for Java type fields.
-  template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
-      ReadBarrierOption kReadBarrierOption = kWithReadBarrier, bool kIsVolatile = false>
+  template<class T,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
+           ReadBarrierOption kReadBarrierOption = kWithReadBarrier,
+           bool kIsVolatile = false>
   ALWAYS_INLINE T* GetFieldObject(MemberOffset field_offset)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
-      ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
+  template<class T,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
+           ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
   ALWAYS_INLINE T* GetFieldObjectVolatile(MemberOffset field_offset)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
@@ -310,11 +313,11 @@
   template<bool kTransactionActive,
            bool kCheckTransaction = true,
            VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
-  ALWAYS_INLINE void SetFieldObjectVolatile(MemberOffset field_offset,
-                                            ObjPtr<Object> new_value)
+  ALWAYS_INLINE void SetFieldObjectVolatile(MemberOffset field_offset, ObjPtr<Object> new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kCheckTransaction = true, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
+  template<bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
            bool kIsVolatile = false>
   ALWAYS_INLINE void SetFieldObjectTransaction(MemberOffset field_offset, ObjPtr<Object> new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
@@ -416,23 +419,29 @@
   ALWAYS_INLINE int8_t GetFieldByteVolatile(MemberOffset field_offset)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
+           bool kIsVolatile = false>
   ALWAYS_INLINE void SetFieldBoolean(MemberOffset field_offset, uint8_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
+           bool kIsVolatile = false>
   ALWAYS_INLINE void SetFieldByte(MemberOffset field_offset, int8_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   ALWAYS_INLINE void SetFieldBooleanVolatile(MemberOffset field_offset, uint8_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   ALWAYS_INLINE void SetFieldByteVolatile(MemberOffset field_offset, int8_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
@@ -452,23 +461,29 @@
   ALWAYS_INLINE int16_t GetFieldShortVolatile(MemberOffset field_offset)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
+           bool kIsVolatile = false>
   ALWAYS_INLINE void SetFieldChar(MemberOffset field_offset, uint16_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
+           bool kIsVolatile = false>
   ALWAYS_INLINE void SetFieldShort(MemberOffset field_offset, int16_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   ALWAYS_INLINE void SetFieldCharVolatile(MemberOffset field_offset, uint16_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   ALWAYS_INLINE void SetFieldShortVolatile(MemberOffset field_offset, int16_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
@@ -487,13 +502,16 @@
     return GetField32<kVerifyFlags, true>(field_offset);
   }
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
+           bool kIsVolatile = false>
   ALWAYS_INLINE void SetField32(MemberOffset field_offset, int32_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   ALWAYS_INLINE void SetField32Volatile(MemberOffset field_offset, int32_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
@@ -503,34 +521,44 @@
   ALWAYS_INLINE void SetField32Transaction(MemberOffset field_offset, int32_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   ALWAYS_INLINE bool CasFieldWeakSequentiallyConsistent32(MemberOffset field_offset,
-                                                          int32_t old_value, int32_t new_value)
+                                                          int32_t old_value,
+                                                          int32_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
-  bool CasFieldWeakRelaxed32(MemberOffset field_offset, int32_t old_value,
-                             int32_t new_value) ALWAYS_INLINE
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  ALWAYS_INLINE bool CasFieldWeakRelaxed32(MemberOffset field_offset,
+                                           int32_t old_value,
+                                           int32_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
-  bool CasFieldWeakAcquire32(MemberOffset field_offset, int32_t old_value,
-                             int32_t new_value) ALWAYS_INLINE
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  ALWAYS_INLINE bool CasFieldWeakAcquire32(MemberOffset field_offset,
+                                           int32_t old_value,
+                                           int32_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
-  bool CasFieldWeakRelease32(MemberOffset field_offset, int32_t old_value,
-                             int32_t new_value) ALWAYS_INLINE
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  ALWAYS_INLINE bool CasFieldWeakRelease32(MemberOffset field_offset,
+                                           int32_t old_value,
+                                           int32_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
-  bool CasFieldStrongSequentiallyConsistent32(MemberOffset field_offset, int32_t old_value,
-                                              int32_t new_value) ALWAYS_INLINE
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  ALWAYS_INLINE bool CasFieldStrongSequentiallyConsistent32(MemberOffset field_offset,
+                                                            int32_t old_value,
+                                                            int32_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
   template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
@@ -548,13 +576,16 @@
     return GetField64<kVerifyFlags, true>(field_offset);
   }
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
+           bool kIsVolatile = false>
   ALWAYS_INLINE void SetField64(MemberOffset field_offset, int64_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   ALWAYS_INLINE void SetField64Volatile(MemberOffset field_offset, int64_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
@@ -564,35 +595,45 @@
   ALWAYS_INLINE void SetField64Transaction(MemberOffset field_offset, int32_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
-  bool CasFieldWeakSequentiallyConsistent64(MemberOffset field_offset, int64_t old_value,
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  bool CasFieldWeakSequentiallyConsistent64(MemberOffset field_offset,
+                                            int64_t old_value,
                                             int64_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
-  bool CasFieldStrongSequentiallyConsistent64(MemberOffset field_offset, int64_t old_value,
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  bool CasFieldStrongSequentiallyConsistent64(MemberOffset field_offset,
+                                              int64_t old_value,
                                               int64_t new_value)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
+           typename T>
   void SetFieldPtr(MemberOffset field_offset, T new_value)
       REQUIRES_SHARED(Locks::mutator_lock_) {
     SetFieldPtrWithSize<kTransactionActive, kCheckTransaction, kVerifyFlags>(
         field_offset, new_value, kRuntimePointerSize);
   }
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
+           typename T>
   void SetFieldPtr64(MemberOffset field_offset, T new_value)
       REQUIRES_SHARED(Locks::mutator_lock_) {
     SetFieldPtrWithSize<kTransactionActive, kCheckTransaction, kVerifyFlags>(
         field_offset, new_value, 8u);
   }
 
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
+           typename T>
   ALWAYS_INLINE void SetFieldPtrWithSize(MemberOffset field_offset,
                                          T new_value,
                                          PointerSize pointer_size)
@@ -628,28 +669,34 @@
   // Update methods that expose the raw address of a primitive value-type to an Accessor instance
   // that will attempt to update the field. These are used by VarHandle accessor methods to
   // atomically update fields with a wider range of memory orderings than usually required.
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   void UpdateFieldBooleanViaAccessor(MemberOffset field_offset, Accessor<uint8_t>* accessor)
       REQUIRES_SHARED(Locks::mutator_lock_);
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   void UpdateFieldByteViaAccessor(MemberOffset field_offset, Accessor<int8_t>* accessor)
       REQUIRES_SHARED(Locks::mutator_lock_);
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   void UpdateFieldCharViaAccessor(MemberOffset field_offset, Accessor<uint16_t>* accessor)
       REQUIRES_SHARED(Locks::mutator_lock_);
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   void UpdateFieldShortViaAccessor(MemberOffset field_offset, Accessor<int16_t>* accessor)
       REQUIRES_SHARED(Locks::mutator_lock_);
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   void UpdateField32ViaAccessor(MemberOffset field_offset, Accessor<int32_t>* accessor)
       REQUIRES_SHARED(Locks::mutator_lock_);
-  template<bool kTransactionActive, bool kCheckTransaction = true,
-      VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+  template<bool kTransactionActive,
+           bool kCheckTransaction = true,
+           VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
   void UpdateField64ViaAccessor(MemberOffset field_offset, Accessor<int64_t>* accessor)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
diff --git a/runtime/mirror/var_handle.cc b/runtime/mirror/var_handle.cc
index 8311d91..71f41b9 100644
--- a/runtime/mirror/var_handle.cc
+++ b/runtime/mirror/var_handle.cc
@@ -27,6 +27,7 @@
 #include "jvalue-inl.h"
 #include "method_handles-inl.h"
 #include "method_type.h"
+#include "obj_ptr-inl.h"
 #include "well_known_classes.h"
 
 namespace art {
@@ -266,31 +267,22 @@
 
 // Returns the return type associated with an AccessModeTemplate based
 // on the template and the variable type specified.
-Class* GetReturnType(AccessModeTemplate access_mode_template, ObjPtr<Class> varType)
+static ObjPtr<Class> GetReturnType(AccessModeTemplate access_mode_template, ObjPtr<Class> varType)
     REQUIRES_SHARED(Locks::mutator_lock_) {
   DCHECK(varType != nullptr);
   switch (access_mode_template) {
     case AccessModeTemplate::kCompareAndSet:
-      return Runtime::Current()->GetClassLinker()->FindPrimitiveClass('Z');
+      return GetClassRoot(ClassRoot::kPrimitiveBoolean);
     case AccessModeTemplate::kCompareAndExchange:
     case AccessModeTemplate::kGet:
     case AccessModeTemplate::kGetAndUpdate:
-      return varType.Ptr();
+      return varType;
     case AccessModeTemplate::kSet:
-      return Runtime::Current()->GetClassLinker()->FindPrimitiveClass('V');
+      return GetClassRoot(ClassRoot::kPrimitiveVoid);
   }
   return nullptr;
 }
 
-ObjectArray<Class>* NewArrayOfClasses(Thread* self, int count)
-    REQUIRES_SHARED(Locks::mutator_lock_) {
-  Runtime* const runtime = Runtime::Current();
-  ClassLinker* const class_linker = runtime->GetClassLinker();
-  ObjPtr<mirror::Class> class_type = mirror::Class::GetJavaLangClass();
-  ObjPtr<mirror::Class> array_of_class = class_linker->FindArrayClass(self, &class_type);
-  return ObjectArray<Class>::Alloc(Thread::Current(), array_of_class, count);
-}
-
 // Method to insert a read barrier for accessors to reference fields.
 inline void ReadBarrierForVarHandleAccess(ObjPtr<Object> obj, MemberOffset field_offset)
     REQUIRES_SHARED(Locks::mutator_lock_) {
@@ -1410,15 +1402,15 @@
 
 }  // namespace
 
-Class* VarHandle::GetVarType() {
+ObjPtr<Class> VarHandle::GetVarType() {
   return GetFieldObject<Class>(VarTypeOffset());
 }
 
-Class* VarHandle::GetCoordinateType0() {
+ObjPtr<Class> VarHandle::GetCoordinateType0() {
   return GetFieldObject<Class>(CoordinateType0Offset());
 }
 
-Class* VarHandle::GetCoordinateType1() {
+ObjPtr<Class> VarHandle::GetCoordinateType1() {
   return GetFieldObject<Class>(CoordinateType1Offset());
 }
 
@@ -1438,7 +1430,7 @@
   // Check return type first. If the return type of the method
   // of the VarHandle is immaterial.
   if (mt_rtype->GetPrimitiveType() != Primitive::Type::kPrimVoid) {
-    ObjPtr<Class> vh_rtype = GetReturnType(access_mode_template, var_type.Ptr());
+    ObjPtr<Class> vh_rtype = GetReturnType(access_mode_template, var_type);
     if (vh_rtype != mt_rtype) {
       if (!IsReturnTypeConvertible(vh_rtype, mt_rtype)) {
         return MatchKind::kNone;
@@ -1513,9 +1505,9 @@
   return true;
 }
 
-MethodType* VarHandle::GetMethodTypeForAccessMode(Thread* self,
-                                                  ObjPtr<VarHandle> var_handle,
-                                                  AccessMode access_mode) {
+ObjPtr<MethodType> VarHandle::GetMethodTypeForAccessMode(Thread* self,
+                                                         ObjPtr<VarHandle> var_handle,
+                                                         AccessMode access_mode) {
   // This is a static method as the var_handle might be moved by the GC during it's execution.
   AccessModeTemplate access_mode_template = GetAccessModeTemplate(access_mode);
 
@@ -1525,7 +1517,9 @@
   const int32_t ptypes_count = GetNumberOfParameters(access_mode_template,
                                                      vh->GetCoordinateType0(),
                                                      vh->GetCoordinateType1());
-  Handle<ObjectArray<Class>> ptypes = hs.NewHandle(NewArrayOfClasses(self, ptypes_count));
+  ObjPtr<Class> array_of_class = GetClassRoot<ObjectArray<Class>>();
+  Handle<ObjectArray<Class>> ptypes =
+      hs.NewHandle(ObjectArray<Class>::Alloc(Thread::Current(), array_of_class, ptypes_count));
   if (ptypes == nullptr) {
     return nullptr;
   }
@@ -1537,12 +1531,12 @@
                       vh->GetCoordinateType0(),
                       vh->GetCoordinateType1());
   for (int32_t i = 0; i < ptypes_count; ++i) {
-    ptypes->Set(i, ptypes_array[i].Ptr());
+    ptypes->Set(i, ptypes_array[i]);
   }
   return MethodType::Create(self, rtype, ptypes);
 }
 
-MethodType* VarHandle::GetMethodTypeForAccessMode(Thread* self, AccessMode access_mode) {
+ObjPtr<MethodType> VarHandle::GetMethodTypeForAccessMode(Thread* self, AccessMode access_mode) {
   return GetMethodTypeForAccessMode(self, this, access_mode);
 }
 
diff --git a/runtime/mirror/var_handle.h b/runtime/mirror/var_handle.h
index 9829456..48c9d74 100644
--- a/runtime/mirror/var_handle.h
+++ b/runtime/mirror/var_handle.h
@@ -26,6 +26,7 @@
 
 template<class T> class Handle;
 class InstructionOperands;
+template<class T> class ObjPtr;
 
 enum class Intrinsics;
 
@@ -120,7 +121,7 @@
   // AccessMode. No check is made for whether the AccessMode is a
   // supported operation so the MethodType can be used when raising a
   // WrongMethodTypeException exception.
-  MethodType* GetMethodTypeForAccessMode(Thread* self, AccessMode accessMode)
+  ObjPtr<MethodType> GetMethodTypeForAccessMode(Thread* self, AccessMode accessMode)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
   // Returns a string representing the descriptor of the MethodType associated with
@@ -135,7 +136,7 @@
       REQUIRES_SHARED(Locks::mutator_lock_);
 
   // Gets the variable type that is operated on by this VarHandle instance.
-  Class* GetVarType() REQUIRES_SHARED(Locks::mutator_lock_);
+  ObjPtr<Class> GetVarType() REQUIRES_SHARED(Locks::mutator_lock_);
 
   // Gets the return type descriptor for a named accessor method,
   // nullptr if accessor_method is not supported.
@@ -149,13 +150,13 @@
   static bool GetAccessModeByMethodName(const char* method_name, AccessMode* access_mode);
 
  private:
-  Class* GetCoordinateType0() REQUIRES_SHARED(Locks::mutator_lock_);
-  Class* GetCoordinateType1() REQUIRES_SHARED(Locks::mutator_lock_);
+  ObjPtr<Class> GetCoordinateType0() REQUIRES_SHARED(Locks::mutator_lock_);
+  ObjPtr<Class> GetCoordinateType1() REQUIRES_SHARED(Locks::mutator_lock_);
   int32_t GetAccessModesBitMask() REQUIRES_SHARED(Locks::mutator_lock_);
 
-  static MethodType* GetMethodTypeForAccessMode(Thread* self,
-                                                ObjPtr<VarHandle> var_handle,
-                                                AccessMode access_mode)
+  static ObjPtr<MethodType> GetMethodTypeForAccessMode(Thread* self,
+                                                       ObjPtr<VarHandle> var_handle,
+                                                       AccessMode access_mode)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
   static MemberOffset VarTypeOffset() {
diff --git a/runtime/mirror/var_handle_test.cc b/runtime/mirror/var_handle_test.cc
index cb2d628..9df96dd 100644
--- a/runtime/mirror/var_handle_test.cc
+++ b/runtime/mirror/var_handle_test.cc
@@ -130,17 +130,17 @@
   }
 
   // Helper to get the VarType of a VarHandle.
-  static Class* GetVarType(VarHandle* vh) REQUIRES_SHARED(Locks::mutator_lock_) {
+  static ObjPtr<Class> GetVarType(VarHandle* vh) REQUIRES_SHARED(Locks::mutator_lock_) {
     return vh->GetVarType();
   }
 
   // Helper to get the CoordinateType0 of a VarHandle.
-  static Class* GetCoordinateType0(VarHandle* vh) REQUIRES_SHARED(Locks::mutator_lock_) {
+  static ObjPtr<Class> GetCoordinateType0(VarHandle* vh) REQUIRES_SHARED(Locks::mutator_lock_) {
     return vh->GetCoordinateType0();
   }
 
   // Helper to get the CoordinateType1 of a VarHandle.
-  static Class* GetCoordinateType1(VarHandle* vh) REQUIRES_SHARED(Locks::mutator_lock_) {
+  static ObjPtr<Class> GetCoordinateType1(VarHandle* vh) REQUIRES_SHARED(Locks::mutator_lock_) {
     return vh->GetCoordinateType1();
   }
 
@@ -150,7 +150,7 @@
   }
 
  private:
-  static void InitializeVarHandle(VarHandle* vh,
+  static void InitializeVarHandle(ObjPtr<VarHandle> vh,
                                   Handle<Class> var_type,
                                   int32_t access_modes_bit_mask)
       REQUIRES_SHARED(Locks::mutator_lock_) {
@@ -158,7 +158,7 @@
     vh->SetField32<false>(VarHandle::AccessModesBitMaskOffset(), access_modes_bit_mask);
   }
 
-  static void InitializeVarHandle(VarHandle* vh,
+  static void InitializeVarHandle(ObjPtr<VarHandle> vh,
                                   Handle<Class> var_type,
                                   Handle<Class> coordinate_type0,
                                   int32_t access_modes_bit_mask)
@@ -167,7 +167,7 @@
     vh->SetFieldObject<false>(VarHandle::CoordinateType0Offset(), coordinate_type0.Get());
   }
 
-  static void InitializeVarHandle(VarHandle* vh,
+  static void InitializeVarHandle(ObjPtr<VarHandle> vh,
                                   Handle<Class> var_type,
                                   Handle<Class> coordinate_type0,
                                   Handle<Class> coordinate_type1,
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc
index 261178b..c6bdfa1 100644
--- a/runtime/native/java_lang_Class.cc
+++ b/runtime/native/java_lang_Class.cc
@@ -215,17 +215,9 @@
   return soa.AddLocalReference<jstring>(mirror::Class::ComputeName(hs.NewHandle(c)));
 }
 
-// TODO: Move this to mirror::Class ? Other mirror types that commonly appear
-// as arrays have a GetArrayClass() method.
-static ObjPtr<mirror::Class> GetClassArrayClass(Thread* self)
-    REQUIRES_SHARED(Locks::mutator_lock_) {
-  ObjPtr<mirror::Class> class_class = mirror::Class::GetJavaLangClass();
-  return Runtime::Current()->GetClassLinker()->FindArrayClass(self, &class_class);
-}
-
 static jobjectArray Class_getInterfacesInternal(JNIEnv* env, jobject javaThis) {
   ScopedFastNativeObjectAccess soa(env);
-  StackHandleScope<4> hs(soa.Self());
+  StackHandleScope<1> hs(soa.Self());
   Handle<mirror::Class> klass = hs.NewHandle(DecodeClass(soa, javaThis));
 
   if (klass->IsProxyClass()) {
@@ -237,10 +229,12 @@
     return nullptr;
   }
 
+  ClassLinker* linker = Runtime::Current()->GetClassLinker();
   const uint32_t num_ifaces = iface_list->Size();
-  Handle<mirror::Class> class_array_class = hs.NewHandle(GetClassArrayClass(soa.Self()));
-  Handle<mirror::ObjectArray<mirror::Class>> ifaces = hs.NewHandle(
-      mirror::ObjectArray<mirror::Class>::Alloc(soa.Self(), class_array_class.Get(), num_ifaces));
+  ObjPtr<mirror::Class> class_array_class =
+      GetClassRoot<mirror::ObjectArray<mirror::Class>>(linker);
+  ObjPtr<mirror::ObjectArray<mirror::Class>> ifaces =
+      mirror::ObjectArray<mirror::Class>::Alloc(soa.Self(), class_array_class, num_ifaces);
   if (ifaces.IsNull()) {
     DCHECK(soa.Self()->IsExceptionPending());
     return nullptr;
@@ -250,20 +244,21 @@
   // with kActiveTransaction == false.
   DCHECK(!Runtime::Current()->IsActiveTransaction());
 
-  ClassLinker* linker = Runtime::Current()->GetClassLinker();
-  MutableHandle<mirror::Class> interface(hs.NewHandle<mirror::Class>(nullptr));
   for (uint32_t i = 0; i < num_ifaces; ++i) {
     const dex::TypeIndex type_idx = iface_list->GetTypeItem(i).type_idx_;
-    interface.Assign(linker->LookupResolvedType(type_idx, klass.Get()));
-    ifaces->SetWithoutChecks<false>(i, interface.Get());
+    ObjPtr<mirror::Class> interface = linker->LookupResolvedType(type_idx, klass.Get());
+    DCHECK(interface != nullptr);
+    ifaces->SetWithoutChecks<false>(i, interface);
   }
 
-  return soa.AddLocalReference<jobjectArray>(ifaces.Get());
+  return soa.AddLocalReference<jobjectArray>(ifaces);
 }
 
-static mirror::ObjectArray<mirror::Field>* GetDeclaredFields(
-    Thread* self, ObjPtr<mirror::Class> klass, bool public_only, bool force_resolve)
-      REQUIRES_SHARED(Locks::mutator_lock_) {
+static ObjPtr<mirror::ObjectArray<mirror::Field>> GetDeclaredFields(
+    Thread* self,
+    ObjPtr<mirror::Class> klass,
+    bool public_only,
+    bool force_resolve) REQUIRES_SHARED(Locks::mutator_lock_) {
   StackHandleScope<1> hs(self);
   IterationRange<StrideIterator<ArtField>> ifields = klass->GetIFields();
   IterationRange<StrideIterator<ArtField>> sfields = klass->GetSFields();
@@ -672,10 +667,8 @@
       // Pending exception from GetDeclaredClasses.
       return nullptr;
     }
-    ObjPtr<mirror::Class> class_array_class = GetClassArrayClass(soa.Self());
-    if (class_array_class == nullptr) {
-      return nullptr;
-    }
+    ObjPtr<mirror::Class> class_array_class = GetClassRoot<mirror::ObjectArray<mirror::Class>>();
+    DCHECK(class_array_class != nullptr);
     ObjPtr<mirror::ObjectArray<mirror::Class>> empty_array =
         mirror::ObjectArray<mirror::Class>::Alloc(soa.Self(), class_array_class, 0);
     return soa.AddLocalReference<jobjectArray>(empty_array);
diff --git a/runtime/native/java_lang_VMClassLoader.cc b/runtime/native/java_lang_VMClassLoader.cc
index b1511c0..42c7ad5 100644
--- a/runtime/native/java_lang_VMClassLoader.cc
+++ b/runtime/native/java_lang_VMClassLoader.cc
@@ -37,11 +37,11 @@
 // A class so we can be friends with ClassLinker and access internal methods.
 class VMClassLoader {
  public:
-  static mirror::Class* LookupClass(ClassLinker* cl,
-                                    Thread* self,
-                                    const char* descriptor,
-                                    size_t hash,
-                                    ObjPtr<mirror::ClassLoader> class_loader)
+  static ObjPtr<mirror::Class> LookupClass(ClassLinker* cl,
+                                           Thread* self,
+                                           const char* descriptor,
+                                           size_t hash,
+                                           ObjPtr<mirror::ClassLoader> class_loader)
       REQUIRES(!Locks::classlinker_classes_lock_)
       REQUIRES_SHARED(Locks::mutator_lock_) {
     return cl->LookupClass(self, descriptor, hash, class_loader);
diff --git a/runtime/native/java_lang_reflect_Constructor.cc b/runtime/native/java_lang_reflect_Constructor.cc
index 13a8d28..a961cb2 100644
--- a/runtime/native/java_lang_reflect_Constructor.cc
+++ b/runtime/native/java_lang_reflect_Constructor.cc
@@ -20,8 +20,8 @@
 
 #include "art_method-inl.h"
 #include "base/enums.h"
-#include "class_linker-inl.h"
 #include "class_linker.h"
+#include "class_root.h"
 #include "dex/dex_file_annotations.h"
 #include "jni/jni_internal.h"
 #include "mirror/class-inl.h"
@@ -42,12 +42,8 @@
       annotations::GetExceptionTypesForMethod(method);
   if (result_array == nullptr) {
     // Return an empty array instead of a null pointer.
-    ObjPtr<mirror::Class> class_class = mirror::Class::GetJavaLangClass();
-    ObjPtr<mirror::Class> class_array_class =
-        Runtime::Current()->GetClassLinker()->FindArrayClass(soa.Self(), &class_class);
-    if (class_array_class == nullptr) {
-      return nullptr;
-    }
+    ObjPtr<mirror::Class> class_array_class = GetClassRoot<mirror::ObjectArray<mirror::Class>>();
+    DCHECK(class_array_class != nullptr);
     ObjPtr<mirror::ObjectArray<mirror::Class>> empty_array =
         mirror::ObjectArray<mirror::Class>::Alloc(soa.Self(), class_array_class, 0);
     return soa.AddLocalReference<jobjectArray>(empty_array);
diff --git a/runtime/native/java_lang_reflect_Executable.cc b/runtime/native/java_lang_reflect_Executable.cc
index 9a2d302..a40cb9b 100644
--- a/runtime/native/java_lang_reflect_Executable.cc
+++ b/runtime/native/java_lang_reflect_Executable.cc
@@ -20,6 +20,7 @@
 #include "nativehelper/jni_macros.h"
 
 #include "art_method-inl.h"
+#include "class_root.h"
 #include "dex/dex_file_annotations.h"
 #include "handle.h"
 #include "jni/jni_internal.h"
@@ -335,15 +336,6 @@
   return soa.AddLocalReference<jclass>(return_type);
 }
 
-// TODO: Move this to mirror::Class ? Other mirror types that commonly appear
-// as arrays have a GetArrayClass() method. This is duplicated in
-// java_lang_Class.cc as well.
-static ObjPtr<mirror::Class> GetClassArrayClass(Thread* self)
-    REQUIRES_SHARED(Locks::mutator_lock_) {
-  ObjPtr<mirror::Class> class_class = mirror::Class::GetJavaLangClass();
-  return Runtime::Current()->GetClassLinker()->FindArrayClass(self, &class_class);
-}
-
 static jobjectArray Executable_getParameterTypesInternal(JNIEnv* env, jobject javaMethod) {
   ScopedFastNativeObjectAccess soa(env);
   ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod);
@@ -356,10 +348,10 @@
 
   const uint32_t num_params = params->Size();
 
-  StackHandleScope<3> hs(soa.Self());
-  Handle<mirror::Class> class_array_class = hs.NewHandle(GetClassArrayClass(soa.Self()));
+  StackHandleScope<2> hs(soa.Self());
+  ObjPtr<mirror::Class> class_array_class = GetClassRoot<mirror::ObjectArray<mirror::Class>>();
   Handle<mirror::ObjectArray<mirror::Class>> ptypes = hs.NewHandle(
-      mirror::ObjectArray<mirror::Class>::Alloc(soa.Self(), class_array_class.Get(), num_params));
+      mirror::ObjectArray<mirror::Class>::Alloc(soa.Self(), class_array_class, num_params));
   if (ptypes.IsNull()) {
     DCHECK(soa.Self()->IsExceptionPending());
     return nullptr;
diff --git a/runtime/native/java_lang_reflect_Method.cc b/runtime/native/java_lang_reflect_Method.cc
index 52e0494..34455fe 100644
--- a/runtime/native/java_lang_reflect_Method.cc
+++ b/runtime/native/java_lang_reflect_Method.cc
@@ -22,6 +22,7 @@
 #include "base/enums.h"
 #include "class_linker-inl.h"
 #include "class_linker.h"
+#include "class_root.h"
 #include "dex/dex_file_annotations.h"
 #include "jni/jni_internal.h"
 #include "mirror/class-inl.h"
@@ -66,12 +67,8 @@
         annotations::GetExceptionTypesForMethod(method);
     if (result_array == nullptr) {
       // Return an empty array instead of a null pointer
-      ObjPtr<mirror::Class> class_class = mirror::Class::GetJavaLangClass();
-      ObjPtr<mirror::Class> class_array_class =
-          Runtime::Current()->GetClassLinker()->FindArrayClass(soa.Self(), &class_class);
-      if (class_array_class == nullptr) {
-        return nullptr;
-      }
+      ObjPtr<mirror::Class> class_array_class = GetClassRoot<mirror::ObjectArray<mirror::Class>>();
+      DCHECK(class_array_class != nullptr);
       mirror::ObjectArray<mirror::Class>* empty_array =
           mirror::ObjectArray<mirror::Class>::Alloc(soa.Self(), class_array_class, 0);
       return soa.AddLocalReference<jobjectArray>(empty_array);
diff --git a/runtime/proxy_test.cc b/runtime/proxy_test.cc
index 4e0bf89..946ea01 100644
--- a/runtime/proxy_test.cc
+++ b/runtime/proxy_test.cc
@@ -44,9 +44,9 @@
   ASSERT_TRUE(I != nullptr);
   ASSERT_TRUE(J != nullptr);
 
-  std::vector<mirror::Class*> interfaces;
-  interfaces.push_back(I.Get());
-  interfaces.push_back(J.Get());
+  std::vector<Handle<mirror::Class>> interfaces;
+  interfaces.push_back(I);
+  interfaces.push_back(J);
   Handle<mirror::Class> proxy_class(hs.NewHandle(
       GenerateProxyClass(soa, jclass_loader, class_linker_, "$Proxy1234", interfaces)));
   interfaces.clear();  // Don't least possibly stale objects in the array as good practice.
@@ -80,9 +80,9 @@
 
   Handle<mirror::Class> proxyClass;
   {
-    std::vector<mirror::Class*> interfaces;
-    interfaces.push_back(I.Get());
-    interfaces.push_back(J.Get());
+    std::vector<Handle<mirror::Class>> interfaces;
+    interfaces.push_back(I);
+    interfaces.push_back(J);
     proxyClass = hs.NewHandle(
         GenerateProxyClass(soa, jclass_loader, class_linker_, "$Proxy1234", interfaces));
   }
@@ -131,7 +131,7 @@
   Handle<mirror::Class> proxyClass0;
   Handle<mirror::Class> proxyClass1;
   {
-    std::vector<mirror::Class*> interfaces;
+    std::vector<Handle<mirror::Class>> interfaces;
     proxyClass0 = hs.NewHandle(
         GenerateProxyClass(soa, jclass_loader, class_linker_, "$Proxy0", interfaces));
     proxyClass1 = hs.NewHandle(
diff --git a/runtime/proxy_test.h b/runtime/proxy_test.h
index fa5a449..860d96c 100644
--- a/runtime/proxy_test.h
+++ b/runtime/proxy_test.h
@@ -25,6 +25,7 @@
 #include "class_root.h"
 #include "mirror/class-inl.h"
 #include "mirror/method.h"
+#include "obj_ptr-inl.h"
 
 namespace art {
 namespace proxy_test {
@@ -32,11 +33,11 @@
 // Generate a proxy class with the given name and interfaces. This is a simplification from what
 // libcore does to fit to our test needs. We do not check for duplicated interfaces or methods and
 // we do not declare exceptions.
-mirror::Class* GenerateProxyClass(ScopedObjectAccess& soa,
-                                  jobject jclass_loader,
-                                  ClassLinker* class_linker,
-                                  const char* className,
-                                  const std::vector<mirror::Class*>& interfaces)
+ObjPtr<mirror::Class> GenerateProxyClass(ScopedObjectAccess& soa,
+                                         jobject jclass_loader,
+                                         ClassLinker* class_linker,
+                                         const char* className,
+                                         const std::vector<Handle<mirror::Class>>& interfaces)
     REQUIRES_SHARED(Locks::mutator_lock_) {
   StackHandleScope<1> hs(soa.Self());
   Handle<mirror::Class> javaLangObject = hs.NewHandle(
@@ -46,21 +47,23 @@
   jclass javaLangClass = soa.AddLocalReference<jclass>(mirror::Class::GetJavaLangClass());
 
   // Builds the interfaces array.
-  jobjectArray proxyClassInterfaces = soa.Env()->NewObjectArray(interfaces.size(), javaLangClass,
-                                                                nullptr);
+  jobjectArray proxyClassInterfaces =
+      soa.Env()->NewObjectArray(interfaces.size(), javaLangClass, /* initialElement */ nullptr);
   soa.Self()->AssertNoPendingException();
   for (size_t i = 0; i < interfaces.size(); ++i) {
     soa.Env()->SetObjectArrayElement(proxyClassInterfaces, i,
-                                     soa.AddLocalReference<jclass>(interfaces[i]));
+                                     soa.AddLocalReference<jclass>(interfaces[i].Get()));
   }
 
   // Builds the method array.
   jsize methods_count = 3;  // Object.equals, Object.hashCode and Object.toString.
-  for (mirror::Class* interface : interfaces) {
+  for (Handle<mirror::Class> interface : interfaces) {
     methods_count += interface->NumVirtualMethods();
   }
   jobjectArray proxyClassMethods = soa.Env()->NewObjectArray(
-      methods_count, soa.AddLocalReference<jclass>(GetClassRoot<mirror::Method>()), nullptr);
+      methods_count,
+      soa.AddLocalReference<jclass>(GetClassRoot<mirror::Method>()),
+      /* initialElement */ nullptr);
   soa.Self()->AssertNoPendingException();
 
   jsize array_index = 0;
@@ -91,7 +94,7 @@
       proxyClassMethods, array_index++, soa.AddLocalReference<jobject>(
           mirror::Method::CreateFromArtMethod<kRuntimePointerSize, false>(soa.Self(), method)));
   // Now adds all interfaces virtual methods.
-  for (mirror::Class* interface : interfaces) {
+  for (Handle<mirror::Class> interface : interfaces) {
     for (auto& m : interface->GetDeclaredVirtualMethods(kRuntimePointerSize)) {
       soa.Env()->SetObjectArrayElement(
           proxyClassMethods, array_index++, soa.AddLocalReference<jobject>(
@@ -104,9 +107,13 @@
   jobjectArray proxyClassThrows = soa.Env()->NewObjectArray(0, javaLangClass, nullptr);
   soa.Self()->AssertNoPendingException();
 
-  mirror::Class* proxyClass = class_linker->CreateProxyClass(
-      soa, soa.Env()->NewStringUTF(className), proxyClassInterfaces, jclass_loader,
-      proxyClassMethods, proxyClassThrows);
+  ObjPtr<mirror::Class> proxyClass = class_linker->CreateProxyClass(
+      soa,
+      soa.Env()->NewStringUTF(className),
+      proxyClassInterfaces,
+      jclass_loader,
+      proxyClassMethods,
+      proxyClassThrows);
   soa.Self()->AssertNoPendingException();
   return proxyClass;
 }
diff --git a/runtime/reflection_test.cc b/runtime/reflection_test.cc
index d2d720f..424ee06 100644
--- a/runtime/reflection_test.cc
+++ b/runtime/reflection_test.cc
@@ -80,7 +80,7 @@
 
   jclass GetPrimitiveClass(char descriptor) {
     ScopedObjectAccess soa(env_);
-    mirror::Class* c = class_linker_->FindPrimitiveClass(descriptor);
+    ObjPtr<mirror::Class> c = class_linker_->FindPrimitiveClass(descriptor);
     CHECK(c != nullptr);
     return soa.AddLocalReference<jclass>(c);
   }
@@ -518,7 +518,7 @@
       hs.NewHandle(soa.Decode<mirror::ClassLoader>(jclass_loader)));
   CompileDirectMethod(class_loader, "Main", "main", "([Ljava/lang/String;)V");
 
-  mirror::Class* klass = class_linker_->FindClass(soa.Self(), "LMain;", class_loader);
+  ObjPtr<mirror::Class> klass = class_linker_->FindClass(soa.Self(), "LMain;", class_loader);
   ASSERT_TRUE(klass != nullptr);
 
   ArtMethod* method = klass->FindClassMethod("main",
diff --git a/runtime/stack_map.h b/runtime/stack_map.h
index 9d66b31..c558846 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -675,7 +675,7 @@
   uint32_t GetStackMaskIndex() const { return Get<kStackMaskIndex>(); }
 
   static uint32_t PackNativePc(uint32_t native_pc, InstructionSet isa) {
-    // TODO: DCHECK_ALIGNED_PARAM(native_pc, GetInstructionSetInstructionAlignment(isa));
+    DCHECK_ALIGNED_PARAM(native_pc, GetInstructionSetInstructionAlignment(isa));
     return native_pc / GetInstructionSetInstructionAlignment(isa);
   }
 
diff --git a/runtime/thread.cc b/runtime/thread.cc
index ab1a4bb..b59606a 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -2862,27 +2862,18 @@
   ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
 
   StackHandleScope<6> hs(soa.Self());
-  mirror::Class* aste_array_class = class_linker->FindClass(
+  Handle<mirror::Class> h_aste_array_class = hs.NewHandle(class_linker->FindSystemClass(
       soa.Self(),
-      "[Ldalvik/system/AnnotatedStackTraceElement;",
-      ScopedNullHandle<mirror::ClassLoader>());
-  if (aste_array_class == nullptr) {
+      "[Ldalvik/system/AnnotatedStackTraceElement;"));
+  if (h_aste_array_class == nullptr) {
     return nullptr;
   }
-  Handle<mirror::Class> h_aste_array_class(hs.NewHandle<mirror::Class>(aste_array_class));
+  Handle<mirror::Class> h_aste_class = hs.NewHandle(h_aste_array_class->GetComponentType());
 
-  mirror::Class* o_array_class = class_linker->FindClass(soa.Self(),
-                                                         "[Ljava/lang/Object;",
-                                                         ScopedNullHandle<mirror::ClassLoader>());
-  if (o_array_class == nullptr) {
-    // This should not fail in a healthy runtime.
-    soa.Self()->AssertPendingException();
-    return nullptr;
-  }
-  Handle<mirror::Class> h_o_array_class(hs.NewHandle<mirror::Class>(o_array_class));
+  Handle<mirror::Class> h_o_array_class =
+      hs.NewHandle(GetClassRoot<mirror::ObjectArray<mirror::Object>>(class_linker));
+  DCHECK(h_o_array_class != nullptr);  // Class roots must be already initialized.
 
-  Handle<mirror::Class> h_aste_class(hs.NewHandle<mirror::Class>(
-      h_aste_array_class->GetComponentType()));
 
   // Make sure the AnnotatedStackTraceElement.class is initialized, b/76208924 .
   class_linker->EnsureInitialized(soa.Self(),
@@ -2906,7 +2897,7 @@
 
   size_t length = dumper.stack_trace_elements_.size();
   ObjPtr<mirror::ObjectArray<mirror::Object>> array =
-      mirror::ObjectArray<mirror::Object>::Alloc(soa.Self(), aste_array_class, length);
+      mirror::ObjectArray<mirror::Object>::Alloc(soa.Self(), h_aste_array_class.Get(), length);
   if (array == nullptr) {
     soa.Self()->AssertPendingOOMException();
     return nullptr;
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 8169568..f4967f7 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -145,7 +145,7 @@
 }
 
 FailureKind MethodVerifier::VerifyClass(Thread* self,
-                                        mirror::Class* klass,
+                                        ObjPtr<mirror::Class> klass,
                                         CompilerCallbacks* callbacks,
                                         bool allow_soft_failures,
                                         HardFailLogMode log_level,
diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h
index c7368d7..9890af9 100644
--- a/runtime/verifier/method_verifier.h
+++ b/runtime/verifier/method_verifier.h
@@ -96,7 +96,7 @@
  public:
   // Verify a class. Returns "kNoFailure" on success.
   static FailureKind VerifyClass(Thread* self,
-                                 mirror::Class* klass,
+                                 ObjPtr<mirror::Class> klass,
                                  CompilerCallbacks* callbacks,
                                  bool allow_soft_failures,
                                  HardFailLogMode log_level,
diff --git a/runtime/verifier/method_verifier_test.cc b/runtime/verifier/method_verifier_test.cc
index db3f093..d1be9fa 100644
--- a/runtime/verifier/method_verifier_test.cc
+++ b/runtime/verifier/method_verifier_test.cc
@@ -37,7 +37,7 @@
       REQUIRES_SHARED(Locks::mutator_lock_) {
     ASSERT_TRUE(descriptor != nullptr);
     Thread* self = Thread::Current();
-    mirror::Class* klass = class_linker_->FindSystemClass(self, descriptor.c_str());
+    ObjPtr<mirror::Class> klass = class_linker_->FindSystemClass(self, descriptor.c_str());
 
     // Verify the class
     std::string error_msg;
diff --git a/tools/teardown-buildbot-device.sh b/tools/teardown-buildbot-device.sh
index df239a2..bf14ca4 100755
--- a/tools/teardown-buildbot-device.sh
+++ b/tools/teardown-buildbot-device.sh
@@ -25,6 +25,27 @@
 adb wait-for-device
 
 if [[ -n "$ART_TEST_CHROOT" ]]; then
+
+  # remove_filesystem_from_chroot DIR-IN-CHROOT FSTYPE REMOVE-DIR-IN-CHROOT
+  # -----------------------------------------------------------------------
+  # Unmount filesystem with type FSTYPE mounted in directory DIR-IN-CHROOT
+  # under the chroot directory.
+  # Remove DIR-IN-CHROOT under the chroot if REMOVE-DIR-IN-CHROOT is
+  # true.
+  remove_filesystem_from_chroot() {
+    local dir_in_chroot=$1
+    local fstype=$2
+    local remove_dir=$3
+    local dir="$ART_TEST_CHROOT/$dir_in_chroot"
+    adb shell test -d "$dir" \
+      && adb shell mount | grep -q "^$fstype on $dir type $fstype " \
+      && if adb shell umount "$dir"; then
+           $remove_dir && adb shell rmdir "$dir"
+         else
+           adb shell lsof "$dir"
+         fi
+  }
+
   # Tear down the chroot dir.
   echo -e "${green}Tear down the chroot dir in $ART_TEST_CHROOT${nc}"
 
@@ -32,22 +53,17 @@
   [[ "x$ART_TEST_CHROOT" = x/* ]] || { echo "$ART_TEST_CHROOT is not an absolute path"; exit 1; }
 
   # Remove /dev from chroot.
-  adb shell mount | grep -q "^tmpfs on $ART_TEST_CHROOT/dev type tmpfs " \
-    && adb shell umount "$ART_TEST_CHROOT/dev" \
-    && adb shell rmdir "$ART_TEST_CHROOT/dev"
+  remove_filesystem_from_chroot dev tmpfs true
 
   # Remove /sys/kernel/debug from chroot.
-  adb shell mount | grep -q "^debugfs on $ART_TEST_CHROOT/sys/kernel/debug type debugfs " \
-    && adb shell umount "$ART_TEST_CHROOT/sys/kernel/debug"
+  # The /sys/kernel/debug directory under the chroot dir cannot be
+  # deleted, as it is part of the host device's /sys filesystem.
+  remove_filesystem_from_chroot sys/kernel/debug debugfs false
   # Remove /sys from chroot.
-  adb shell mount | grep -q "^sysfs on $ART_TEST_CHROOT/sys type sysfs " \
-    && adb shell umount "$ART_TEST_CHROOT/sys" \
-    && adb shell rmdir "$ART_TEST_CHROOT/sys"
+  remove_filesystem_from_chroot sys sysfs true
 
   # Remove /proc from chroot.
-  adb shell mount | grep -q "^proc on $ART_TEST_CHROOT/proc type proc " \
-    && adb shell umount "$ART_TEST_CHROOT/proc" \
-    && adb shell rmdir "$ART_TEST_CHROOT/proc"
+  remove_filesystem_from_chroot proc proc true
 
   # Remove /etc from chroot.
   adb shell rm -f "$ART_TEST_CHROOT/etc"
@@ -65,6 +81,6 @@
     /plat_property_contexts \
     /nonplat_property_contexts"
   for f in $property_context_files; do
-    adb shell test -f "$f" "&&" rm -f "$ART_TEST_CHROOT$f"
+    adb shell rm -f "$ART_TEST_CHROOT$f"
   done
 fi
diff --git a/tools/veridex/Android.bp b/tools/veridex/Android.bp
index 5186c43..96d4a09 100644
--- a/tools/veridex/Android.bp
+++ b/tools/veridex/Android.bp
@@ -24,11 +24,16 @@
         "veridex.cc",
     ],
     cflags: ["-Wall", "-Werror"],
-    shared_libs: [
+    static_libs: [
         "libdexfile",
         "libartbase",
         "libbase",
+        "liblog",
+        "libutils",
+        "libz",
+        "libziparchive",
     ],
+    stl: "libc++_static",
     header_libs: [
         "art_libartbase_headers",
     ],
diff --git a/tools/veridex/Android.mk b/tools/veridex/Android.mk
index 51d924a..83fa0d6 100644
--- a/tools/veridex/Android.mk
+++ b/tools/veridex/Android.mk
@@ -16,6 +16,9 @@
 
 LOCAL_PATH := $(call my-dir)
 
+# The veridex tool takes stub dex files as input, so we generate both the system and oahl
+# dex stubs.
+
 system_stub_dex := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/core_dex_intermediates/classes.dex
 $(system_stub_dex): PRIVATE_MIN_SDK_VERSION := 1000
 $(system_stub_dex): $(call resolve-prebuilt-sdk-jar-path,system_current) | $(ZIP2ZIP) $(DX)
@@ -27,9 +30,29 @@
 $(oahl_stub_dex): $(call get-prebuilt-sdk-dir,current)/org.apache.http.legacy.jar | $(ZIP2ZIP) $(DX)
 	$(transform-classes-d8.jar-to-dex)
 
-.PHONY: appcompat
+app_compat_lists := \
+  $(INTERNAL_PLATFORM_HIDDENAPI_LIGHT_GREYLIST) \
+  $(INTERNAL_PLATFORM_HIDDENAPI_DARK_GREYLIST) \
+  $(INTERNAL_PLATFORM_HIDDENAPI_BLACKLIST)
 
-appcompat: $(system_stub_dex) $(oahl_stub_dex) $(HOST_OUT_EXECUTABLES)/veridex \
-  ${TARGET_OUT_COMMON_INTERMEDIATES}/PACKAGING/hiddenapi-light-greylist.txt \
-  ${TARGET_OUT_COMMON_INTERMEDIATES}/PACKAGING/hiddenapi-dark-greylist.txt \
-  ${TARGET_OUT_COMMON_INTERMEDIATES}/PACKAGING/hiddenapi-blacklist.txt
+# Phony rule to create all dependencies of the appcompat.sh script.
+.PHONY: appcompat
+appcompat: $(system_stub_dex) $(oahl_stub_dex) $(HOST_OUT_EXECUTABLES)/veridex $(app_compat_lists)
+
+VERIDEX_FILES_PATH := \
+    $(call intermediates-dir-for,PACKAGING,veridex,HOST)/veridex.zip
+
+VERIDEX_FILES := $(LOCAL_PATH)/appcompat.sh
+
+$(VERIDEX_FILES_PATH): PRIVATE_VERIDEX_FILES := $(VERIDEX_FILES)
+$(VERIDEX_FILES_PATH): PRIVATE_APP_COMPAT_LISTS := $(app_compat_lists)
+$(VERIDEX_FILES_PATH) : $(SOONG_ZIP) $(VERIDEX_FILES) $(app_compat_lists) $(HOST_OUT_EXECUTABLES)/veridex
+	$(hide) $(SOONG_ZIP) -o $@ -C art/tools/veridex -f $(PRIVATE_VERIDEX_FILES) \
+                             -C $(dir $(lastword $(PRIVATE_APP_COMPAT_LISTS))) $(addprefix -f , $(PRIVATE_APP_COMPAT_LISTS)) \
+                             -C $(HOST_OUT_EXECUTABLES) -f $(HOST_OUT_EXECUTABLES)/veridex
+
+# Make the zip file available for prebuilts.
+$(call dist-for-goals,sdk,$(VERIDEX_FILES_PATH))
+
+VERIDEX_FILES :=
+app_compat_lists :=
diff --git a/tools/veridex/appcompat.sh b/tools/veridex/appcompat.sh
index 31a8654..c07ab21 100755
--- a/tools/veridex/appcompat.sh
+++ b/tools/veridex/appcompat.sh
@@ -14,7 +14,28 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# We want to be at the root for simplifying the "out" detection
+echo "NOTE: appcompat.sh is still under development. It can report"
+echo "API uses that do not execute at runtime, and reflection uses"
+echo "that do not exist. It can also miss on reflection uses."
+
+# First check if the script is invoked from a prebuilts location.
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+if [[ -e ${SCRIPT_DIR}/veridex && \
+      -e ${SCRIPT_DIR}/hiddenapi-blacklist.txt && \
+      -e ${SCRIPT_DIR}/hiddenapi-light-greylist.txt && \
+      -e ${SCRIPT_DIR}/hiddenapi-dark-greylist.txt && \
+      -e ${SCRIPT_DIR}/org.apache.http.legacy-stubs.dex && \
+      -e ${SCRIPT_DIR}/system-stubs.dex ]]; then
+  exec ${SCRIPT_DIR}/veridex \
+    --core-stubs=${SCRIPT_DIR}/system-stubs.dex:${SCRIPT_DIR}/org.apache.http.legacy-stubs.dex \
+    --blacklist=${SCRIPT_DIR}/hiddenapi-blacklist.txt \
+    --light-greylist=${SCRIPT_DIR}/hiddenapi-light-greylist.txt \
+    --dark-greylist=${SCRIPT_DIR}/hiddenapi-dark-greylist.txt \
+    $@
+fi
+
+# Otherwise, we want to be at the root for simplifying the "out" detection
 # logic.
 if [ ! -d art ]; then
   echo "Script needs to be run at the root of the android tree."
@@ -38,10 +59,6 @@
   ANDROID_HOST_OUT=${OUT}/host/linux-x86
 fi
 
-echo "NOTE: appcompat.sh is still under development. It can report"
-echo "API uses that do not execute at runtime, and reflection uses"
-echo "that do not exist. It can also miss on reflection uses."
-
 
 ${ANDROID_HOST_OUT}/bin/veridex \
     --core-stubs=${PACKAGING}/core_dex_intermediates/classes.dex:${PACKAGING}/oahl_dex_intermediates/classes.dex \