Remove mirror:: and ArtMethod deps in utils.{h,cc}

The latest chapter in the ongoing saga of attempting to dump a DEX
file without having to start a whole runtime instance.  This episode
finds us removing references to ArtMethod/ArtField/mirror.

One aspect of this change that I would like to call out specfically
is that the utils versions of the "Pretty*" functions all were written
to accept nullptr as an argument.  I have split these functions up as
follows:
1) an instance method, such as PrettyClass that obviously requires
this != nullptr.
2) a static method, that behaves the same way as the util method, but
calls the instance method if p != nullptr.
This requires using a full class qualifier for the static methods,
which isn't exactly beautiful.  I have tried to remove as many cases
as possible where it was clear p != nullptr.

Bug: 22322814
Test: test-art-host
Change-Id: I21adee3614aa697aa580cd1b86b72d9206e1cb24
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index 888fddb..e6de097 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -356,7 +356,6 @@
   if (field == nullptr) {
     return;
   }
-  // LOG(INFO) << "VMRuntime.preloadDexCaches resolved field " << PrettyField(field);
   dex_cache->SetResolvedField(field_idx, field, kRuntimePointerSize);
 }
 
@@ -393,7 +392,6 @@
   if (method == nullptr) {
     return;
   }
-  // LOG(INFO) << "VMRuntime.preloadDexCaches resolved method " << PrettyMethod(method);
   dex_cache->SetResolvedMethod(method_idx, method, kRuntimePointerSize);
 }
 
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc
index ac5dbda..642826c 100644
--- a/runtime/native/java_lang_Class.cc
+++ b/runtime/native/java_lang_Class.cc
@@ -633,7 +633,8 @@
   if (UNLIKELY(klass->GetPrimitiveType() != 0 || klass->IsInterface() || klass->IsArrayClass() ||
                klass->IsAbstract())) {
     soa.Self()->ThrowNewExceptionF("Ljava/lang/InstantiationException;",
-                                   "%s cannot be instantiated", PrettyClass(klass.Get()).c_str());
+                                   "%s cannot be instantiated",
+                                   klass->PrettyClass().c_str());
     return nullptr;
   }
   auto caller = hs.NewHandle<mirror::Class>(nullptr);
@@ -643,7 +644,7 @@
     if (caller.Get() != nullptr && !caller->CanAccess(klass.Get())) {
       soa.Self()->ThrowNewExceptionF(
           "Ljava/lang/IllegalAccessException;", "%s is not accessible from %s",
-          PrettyClass(klass.Get()).c_str(), PrettyClass(caller.Get()).c_str());
+          klass->PrettyClass().c_str(), caller->PrettyClass().c_str());
       return nullptr;
     }
   }
@@ -654,7 +655,7 @@
   if (UNLIKELY(constructor == nullptr)) {
     soa.Self()->ThrowNewExceptionF("Ljava/lang/InstantiationException;",
                                    "%s has no zero argument constructor",
-                                   PrettyClass(klass.Get()).c_str());
+                                   klass->PrettyClass().c_str());
     return nullptr;
   }
   // Invoke the string allocator to return an empty string for the string class.
@@ -684,7 +685,7 @@
                                                           caller.Get()))) {
       soa.Self()->ThrowNewExceptionF(
           "Ljava/lang/IllegalAccessException;", "%s is not accessible from %s",
-          PrettyMethod(constructor).c_str(), PrettyClass(caller.Get()).c_str());
+          constructor->PrettyMethod().c_str(), caller->PrettyClass().c_str());
       return nullptr;
     }
   }
diff --git a/runtime/native/java_lang_System.cc b/runtime/native/java_lang_System.cc
index eaf2d65..7f8da80 100644
--- a/runtime/native/java_lang_System.cc
+++ b/runtime/native/java_lang_System.cc
@@ -38,7 +38,7 @@
 static void ThrowArrayStoreException_NotAnArray(const char* identifier,
                                                 ObjPtr<mirror::Object> array)
     REQUIRES_SHARED(Locks::mutator_lock_) {
-  std::string actualType(PrettyTypeOf(array));
+  std::string actualType(mirror::Object::PrettyTypeOf(array));
   Thread* self = Thread::Current();
   self->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
                            "%s of type %s is not an array", identifier, actualType.c_str());
@@ -128,15 +128,15 @@
         return;
       }
       default:
-        LOG(FATAL) << "Unknown array type: " << PrettyTypeOf(srcArray);
+        LOG(FATAL) << "Unknown array type: " << srcArray->PrettyTypeOf();
         UNREACHABLE();
     }
   }
   // If one of the arrays holds a primitive type the other array must hold the exact same type.
   if (UNLIKELY((dstComponentPrimitiveType != Primitive::kPrimNot) ||
                srcComponentType->IsPrimitive())) {
-    std::string srcType(PrettyTypeOf(srcArray));
-    std::string dstType(PrettyTypeOf(dstArray));
+    std::string srcType(srcArray->PrettyTypeOf());
+    std::string dstType(dstArray->PrettyTypeOf());
     soa.Self()->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
                                    "Incompatible types: src=%s, dst=%s",
                                    srcType.c_str(), dstType.c_str());
diff --git a/runtime/native/java_lang_VMClassLoader.cc b/runtime/native/java_lang_VMClassLoader.cc
index 1fe89bf..ff08284 100644
--- a/runtime/native/java_lang_VMClassLoader.cc
+++ b/runtime/native/java_lang_VMClassLoader.cc
@@ -57,7 +57,7 @@
     ObjPtr<mirror::Class> exception = self->GetException()->GetClass();
     if (exception == eiie_class || exception == iae_class || exception == ncdfe_class) {
       self->ThrowNewWrappedException("Ljava/lang/ClassNotFoundException;",
-                                     PrettyDescriptor(c).c_str());
+                                     c->PrettyDescriptor().c_str());
     }
     return nullptr;
   }
diff --git a/runtime/native/java_lang_reflect_Constructor.cc b/runtime/native/java_lang_reflect_Constructor.cc
index a81ba7d..66a5359 100644
--- a/runtime/native/java_lang_reflect_Constructor.cc
+++ b/runtime/native/java_lang_reflect_Constructor.cc
@@ -66,7 +66,7 @@
   if (UNLIKELY(c->IsAbstract())) {
     soa.Self()->ThrowNewExceptionF("Ljava/lang/InstantiationException;", "Can't instantiate %s %s",
                                    c->IsInterface() ? "interface" : "abstract class",
-                                   PrettyDescriptor(c.Get()).c_str());
+                                   c->PrettyDescriptor().c_str());
     return nullptr;
   }
   // Verify that we can access the class.
@@ -77,7 +77,7 @@
     // If caller is null, then we called from JNI, just avoid the check since JNI avoids most
     // access checks anyways. TODO: Investigate if this the correct behavior.
     if (caller != nullptr && !caller->CanAccess(c.Get())) {
-      if (PrettyDescriptor(c.Get()) == "dalvik.system.DexPathList$Element") {
+      if (c->PrettyDescriptor() == "dalvik.system.DexPathList$Element") {
         // b/20699073.
         LOG(WARNING) << "The dalvik.system.DexPathList$Element constructor is not accessible by "
                         "default. This is a temporary workaround for backwards compatibility "
@@ -85,7 +85,8 @@
       } else {
         soa.Self()->ThrowNewExceptionF(
             "Ljava/lang/IllegalAccessException;", "%s is not accessible from %s",
-            PrettyClass(c.Get()).c_str(), PrettyClass(caller).c_str());
+            c->PrettyClass().c_str(),
+            caller->PrettyClass().c_str());
         return nullptr;
       }
     }
diff --git a/runtime/native/java_lang_reflect_Executable.cc b/runtime/native/java_lang_reflect_Executable.cc
index a0a6a12..1b128fb 100644
--- a/runtime/native/java_lang_reflect_Executable.cc
+++ b/runtime/native/java_lang_reflect_Executable.cc
@@ -102,7 +102,7 @@
   if (UNLIKELY(names.Get() == nullptr || access_flags.Get() == nullptr)) {
     ThrowIllegalArgumentException(
         StringPrintf("Missing parameter metadata for names or access flags for %s",
-                     PrettyMethod(art_method).c_str()).c_str());
+                     art_method->PrettyMethod().c_str()).c_str());
     return nullptr;
   }
 
@@ -113,7 +113,7 @@
     ThrowIllegalArgumentException(
         StringPrintf(
             "Inconsistent parameter metadata for %s. names length: %d, access flags length: %d",
-            PrettyMethod(art_method).c_str(),
+            art_method->PrettyMethod().c_str(),
             names_count,
             access_flags_count).c_str());
     return nullptr;
diff --git a/runtime/native/java_lang_reflect_Field.cc b/runtime/native/java_lang_reflect_Field.cc
index 90def44..329aae9 100644
--- a/runtime/native/java_lang_reflect_Field.cc
+++ b/runtime/native/java_lang_reflect_Field.cc
@@ -39,9 +39,9 @@
     ThrowIllegalAccessException(
             StringPrintf("Cannot set %s field %s of class %s",
                 PrettyJavaAccessFlags(field->GetAccessFlags()).c_str(),
-                PrettyField(field->GetArtField()).c_str(),
+                ArtField::PrettyField(field->GetArtField()).c_str(),
                 field->GetDeclaringClass() == nullptr ? "null" :
-                    PrettyClass(field->GetDeclaringClass()).c_str()).c_str());
+                    field->GetDeclaringClass()->PrettyClass().c_str()).c_str());
     return false;
   }
   ObjPtr<mirror::Class> calling_class;
@@ -53,11 +53,11 @@
                     1)) {
     ThrowIllegalAccessException(
             StringPrintf("Class %s cannot access %s field %s of class %s",
-                calling_class == nullptr ? "null" : PrettyClass(calling_class).c_str(),
+                calling_class == nullptr ? "null" : calling_class->PrettyClass().c_str(),
                 PrettyJavaAccessFlags(field->GetAccessFlags()).c_str(),
-                PrettyField(field->GetArtField()).c_str(),
+                ArtField::PrettyField(field->GetArtField()).c_str(),
                 field->GetDeclaringClass() == nullptr ? "null" :
-                    PrettyClass(field->GetDeclaringClass()).c_str()).c_str());
+                    field->GetDeclaringClass()->PrettyClass().c_str()).c_str());
     return false;
   }
   return true;
@@ -106,7 +106,8 @@
       break;
   }
   ThrowIllegalArgumentException(
-      StringPrintf("Not a primitive field: %s", PrettyField(f->GetArtField()).c_str()).c_str());
+      StringPrintf("Not a primitive field: %s",
+                   ArtField::PrettyField(f->GetArtField()).c_str()).c_str());
   return false;
 }
 
@@ -306,8 +307,9 @@
     FALLTHROUGH_INTENDED;
   case Primitive::kPrimVoid:
     // Never okay.
-    ThrowIllegalArgumentException(StringPrintf("Not a primitive field: %s",
-                                               PrettyField(f->GetArtField()).c_str()).c_str());
+    ThrowIllegalArgumentException(
+        StringPrintf("Not a primitive field: %s",
+                     ArtField::PrettyField(f->GetArtField()).c_str()).c_str());
     return;
   }
 }
@@ -362,8 +364,9 @@
   }
   Primitive::Type field_type = f->GetTypeAsPrimitiveType();
   if (UNLIKELY(field_type == Primitive::kPrimNot)) {
-    ThrowIllegalArgumentException(StringPrintf("Not a primitive field: %s",
-                                               PrettyField(f->GetArtField()).c_str()).c_str());
+    ThrowIllegalArgumentException(
+        StringPrintf("Not a primitive field: %s",
+                     ArtField::PrettyField(f->GetArtField()).c_str()).c_str());
     return;
   }
 
diff --git a/runtime/native/java_lang_reflect_Parameter.cc b/runtime/native/java_lang_reflect_Parameter.cc
index 6060b8a..16164d2 100644
--- a/runtime/native/java_lang_reflect_Parameter.cc
+++ b/runtime/native/java_lang_reflect_Parameter.cc
@@ -47,7 +47,7 @@
     ThrowIllegalArgumentException(
         StringPrintf("Illegal parameterIndex %d for %s, parameter_count is %d",
                      parameterIndex,
-                     PrettyMethod(method).c_str(),
+                     method->PrettyMethod().c_str(),
                      parameter_count).c_str());
     return nullptr;
   }