Add ClassLinker::VisitRoots

As part of implementing VisitRoots, created ClassLinker::class_roots_
with enum of offsets. This required revising ClassLinker::Init yet
again, so took the opportunity to simplify and document ordering
restrictions. Also simplified special cases in FindClass, as well as
making a fast path for FindClass and CreateArrayClass for post
::Init. Made ClassLinker::Alloc* conveniences private after realizing
they are only used externally by tests. Sprinkled some
Class::IsSynthetic validation in ClassLinkerTest along with adding a
test for VisitRoots. Updated kJavaLangDex to have a java.lang.String
to work with the simplified ::Init code.

Change-Id: I76b92c0bde5da32d9ebc8d3702d8e7ac7972dda7
diff --git a/src/object.h b/src/object.h
index 05071cc..fbeac8f 100644
--- a/src/object.h
+++ b/src/object.h
@@ -771,10 +771,12 @@
   }
 
   Method* GetDirectMethod(uint32_t i) const {
+    DCHECK_NE(NumDirectMethods(), 0U);
     return direct_methods_->Get(i);
   }
 
   void SetDirectMethod(uint32_t i, Method* f) {  // TODO: uint16_t
+    DCHECK_NE(NumDirectMethods(), 0U);
     direct_methods_->Set(i, f);
   }
 
@@ -784,10 +786,12 @@
   }
 
   Method* GetVirtualMethod(uint32_t i) const {
+    DCHECK_NE(NumVirtualMethods(), 0U);
     return virtual_methods_->Get(i);
   }
 
   void SetVirtualMethod(uint32_t i, Method* f) {  // TODO: uint16_t
+    DCHECK_NE(NumVirtualMethods(), 0U);
     virtual_methods_->Set(i, f);
   }
 
@@ -801,10 +805,12 @@
   }
 
   InstanceField* GetInstanceField(uint32_t i) {  // TODO: uint16_t
+    DCHECK_NE(NumInstanceFields(), 0U);
     return ifields_->Get(i);
   }
 
   void SetInstanceField(uint32_t i, InstanceField* f) {  // TODO: uint16_t
+    DCHECK_NE(NumInstanceFields(), 0U);
     ifields_->Set(i, f);
   }
 
@@ -813,10 +819,12 @@
   }
 
   StaticField* GetStaticField(uint32_t i) const {  // TODO: uint16_t
+    DCHECK_NE(NumStaticFields(), 0U);
     return sfields_->Get(i);
   }
 
   void SetStaticField(uint32_t i, StaticField* f) {  // TODO: uint16_t
+    DCHECK_NE(NumStaticFields(), 0U);
     sfields_->Set(i, f);
   }
 
@@ -837,10 +845,12 @@
   }
 
   Class* GetInterface(uint32_t i) const {
+    DCHECK_NE(NumInterfaces(), 0U);
     return interfaces_->Get(i);
   }
 
   void SetInterface(uint32_t i, Class* f) {  // TODO: uint16_t
+    DCHECK_NE(NumInterfaces(), 0U);
     interfaces_->Set(i, f);
   }