Change dex cache to be java object instead of array, add pointer to dex file in dex cache.

Generic clean up to facilitate having GDB macros for Pretty* helper functions.

Improved cleanliness of DexCache since having it as an object array was not the best solution.

Fixed a bug in InOrderWalk caused by ResolveType sometimes allocating classes.

Rename C++ Method to AbstractMethod and add two new classes Constructor, Method which both inherit from AbstractMethod.

Rename done to have the C++ code be closer to the java code.

Change-Id: I4995b4c5e47a3822192b08afa24a639d3b1f4da9
diff --git a/src/jni_internal.cc b/src/jni_internal.cc
index 6230a66..8c67fb4 100644
--- a/src/jni_internal.cc
+++ b/src/jni_internal.cc
@@ -93,7 +93,7 @@
 
 class ArgArray {
  public:
-  explicit ArgArray(Method* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  explicit ArgArray(AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
     MethodHelper mh(method);
     shorty_ = mh.GetShorty();
     shorty_len_ = mh.GetShortyLength();
@@ -200,7 +200,7 @@
   return reinterpret_cast<jweak>(ref);
 }
 
-static void CheckMethodArguments(Method* m, JValue* args)
+static void CheckMethodArguments(AbstractMethod* m, JValue* args)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   MethodHelper mh(m);
   ObjectArray<Class>* parameter_types = mh.GetParameterTypes();
@@ -226,7 +226,7 @@
 }
 
 static JValue InvokeWithArgArray(const ScopedObjectAccess& soa, Object* receiver,
-                                 Method* method, JValue* args)
+                                 AbstractMethod* method, JValue* args)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   if (UNLIKELY(soa.Env()->check_jni)) {
     CheckMethodArguments(method, args);
@@ -240,13 +240,13 @@
                                 jmethodID mid, va_list args)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   Object* receiver = soa.Decode<Object*>(obj);
-  Method* method = soa.DecodeMethod(mid);
+  AbstractMethod* method = soa.DecodeMethod(mid);
   ArgArray arg_array(method);
   arg_array.BuildArgArray(soa, args);
   return InvokeWithArgArray(soa, receiver, method, arg_array.get());
 }
 
-static Method* FindVirtualMethod(Object* receiver, Method* method)
+static AbstractMethod* FindVirtualMethod(Object* receiver, AbstractMethod* method)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   return receiver->GetClass()->FindVirtualMethodForVirtualOrInterface(method);
 }
@@ -255,7 +255,7 @@
                                                   jobject obj, jmethodID mid, jvalue* args)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   Object* receiver = soa.Decode<Object*>(obj);
-  Method* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid));
+  AbstractMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid));
   ArgArray arg_array(method);
   arg_array.BuildArgArray(soa, args);
   return InvokeWithArgArray(soa, receiver, method, arg_array.get());
@@ -265,7 +265,7 @@
                                                   jobject obj, jmethodID mid, va_list args)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   Object* receiver = soa.Decode<Object*>(obj);
-  Method* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid));
+  AbstractMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid));
   ArgArray arg_array(method);
   arg_array.BuildArgArray(soa, args);
   return InvokeWithArgArray(soa, receiver, method, arg_array.get());
@@ -310,7 +310,7 @@
     return NULL;
   }
 
-  Method* method = NULL;
+  AbstractMethod* method = NULL;
   if (is_static) {
     method = c->FindDirectMethod(name, sig);
   } else {
@@ -332,7 +332,7 @@
 
 static ClassLoader* GetClassLoader(Thread* self)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
-  Method* method = self->GetCurrentMethod();
+  AbstractMethod* method = self->GetCurrentMethod();
   if (method == NULL || PrettyMethod(method, false) == "java.lang.Runtime.nativeLoad") {
     return self->GetClassLoaderOverride();
   }
@@ -614,7 +614,7 @@
   }
 
   // See section 11.3 "Linking Native Methods" of the JNI spec.
-  void* FindNativeMethod(const Method* m, std::string& detail)
+  void* FindNativeMethod(const AbstractMethod* m, std::string& detail)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
     std::string jni_short_name(JniShortName(m));
     std::string jni_long_name(JniLongName(m));
@@ -652,13 +652,13 @@
 JValue InvokeWithJValues(const ScopedObjectAccess& soa, jobject obj, jmethodID mid,
                          jvalue* args) {
   Object* receiver = soa.Decode<Object*>(obj);
-  Method* method = soa.DecodeMethod(mid);
+  AbstractMethod* method = soa.DecodeMethod(mid);
   ArgArray arg_array(method);
   arg_array.BuildArgArray(soa, args);
   return InvokeWithArgArray(soa, receiver, method, arg_array.get());
 }
 
-JValue InvokeWithJValues(const ScopedObjectAccess& soa, Object* receiver, Method* m,
+JValue InvokeWithJValues(const ScopedObjectAccess& soa, Object* receiver, AbstractMethod* m,
                          JValue* args)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   return InvokeWithArgArray(soa, receiver, m, args);
@@ -692,7 +692,7 @@
 
   static jmethodID FromReflectedMethod(JNIEnv* env, jobject java_method) {
     ScopedObjectAccess soa(env);
-    Method* method = soa.Decode<Method*>(java_method);
+    AbstractMethod* method = soa.Decode<AbstractMethod*>(java_method);
     return soa.EncodeMethod(method);
   }
 
@@ -704,7 +704,7 @@
 
   static jobject ToReflectedMethod(JNIEnv* env, jclass, jmethodID mid, jboolean) {
     ScopedObjectAccess soa(env);
-    Method* method = soa.DecodeMethod(mid);
+    AbstractMethod* method = soa.DecodeMethod(mid);
     return soa.AddLocalReference<jobject>(method);
   }
 
@@ -2125,7 +2125,7 @@
         ++sig;
       }
 
-      Method* m = c->FindDirectMethod(name, sig);
+      AbstractMethod* m = c->FindDirectMethod(name, sig);
       if (m == NULL) {
         m = c->FindVirtualMethod(name, sig);
       }
@@ -2153,13 +2153,13 @@
     VLOG(jni) << "[Unregistering JNI native methods for " << PrettyClass(c) << "]";
 
     for (size_t i = 0; i < c->NumDirectMethods(); ++i) {
-      Method* m = c->GetDirectMethod(i);
+      AbstractMethod* m = c->GetDirectMethod(i);
       if (m->IsNative()) {
         m->UnregisterNative(soa.Self());
       }
     }
     for (size_t i = 0; i < c->NumVirtualMethods(); ++i) {
-      Method* m = c->GetVirtualMethod(i);
+      AbstractMethod* m = c->GetVirtualMethod(i);
       if (m->IsNative()) {
         m->UnregisterNative(soa.Self());
       }
@@ -2939,7 +2939,7 @@
   return result;
 }
 
-void* JavaVMExt::FindCodeForNativeMethod(Method* m) {
+void* JavaVMExt::FindCodeForNativeMethod(AbstractMethod* m) {
   CHECK(m->IsNative());
 
   Class* c = m->GetDeclaringClass();