Fix exception throwing to support no detail message.

(The empty string as a detail message is distinct from a NULL detail message,
and is treated differently by Throwable.printStackTrace.)

Change-Id: I8c65deac9f18c5782dcf6e72e4c37e6dd4174fe9
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 1963985..eade908 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -61,7 +61,7 @@
   if (dex_cache) {
     msg << " (defined in " << dex_cache->GetLocation()->ToModifiedUtf8() << ")";
   }
-  Thread::Current()->ThrowNewException("Ljava/lang/NoSuchMethodError;", "%s", msg.str().c_str());
+  Thread::Current()->ThrowNewException("Ljava/lang/NoSuchMethodError;", msg.str().c_str());
 }
 
 void ThrowEarlierClassFailure(Class* c) {
@@ -76,7 +76,7 @@
   if (c->GetVerifyErrorClass() != NULL) {
     // TODO: change the verifier to store an _instance_, with a useful detail message?
     std::string error_descriptor(c->GetVerifyErrorClass()->GetDescriptor()->ToModifiedUtf8());
-    Thread::Current()->ThrowNewException(error_descriptor.c_str(), "%s",
+    Thread::Current()->ThrowNewException(error_descriptor.c_str(),
         PrettyDescriptor(c->GetDescriptor()).c_str());
   } else {
     ThrowNoClassDefFoundError("%s", PrettyDescriptor(c->GetDescriptor()).c_str());
@@ -816,7 +816,7 @@
     ObjectLock lock(klass);
     // Check for circular dependencies between classes.
     if (!klass->IsResolved() && klass->GetClinitThreadId() == self->GetTid()) {
-      self->ThrowNewException("Ljava/lang/ClassCircularityError;", "%s",
+      self->ThrowNewException("Ljava/lang/ClassCircularityError;",
           PrettyDescriptor(klass->GetDescriptor()).c_str());
       return NULL;
     }
@@ -1416,7 +1416,7 @@
     // "interruptShouldThrow" was set), bail out.
     if (self->IsExceptionPending()) {
       // TODO: set cause of ExceptionInInitializerError to self->GetException()
-      self->ThrowNewException("Ljava/lang/ExceptionInInitializerError;",
+      self->ThrowNewExceptionF("Ljava/lang/ExceptionInInitializerError;",
           "Exception %s thrown while initializing class %s",
           PrettyTypeOf(self->GetException()).c_str(),
           PrettyDescriptor(klass->GetDescriptor()).c_str());
@@ -1430,7 +1430,7 @@
     if (klass->IsErroneous()) {
       // The caller wants an exception, but it was thrown in a
       // different thread.  Synthesize one here.
-      self->ThrowNewException("Ljava/lang/NoClassDefFoundError;",
+      self->ThrowNewExceptionF("Ljava/lang/NoClassDefFoundError;",
           "<clinit> failed for class %s; see exception in other thread",
           PrettyDescriptor(klass->GetDescriptor()).c_str());
       return false;
@@ -1722,7 +1722,7 @@
     // Verify
     if (!klass->CanAccess(interface)) {
       // TODO: the RI seemed to ignore this in my testing.
-      Thread::Current()->ThrowNewException("Ljava/lang/IllegalAccessError;",
+      Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalAccessError;",
           "Interface %s implemented by class %s is inaccessible",
           PrettyDescriptor(interface->GetDescriptor()).c_str(),
           PrettyDescriptor(klass->GetDescriptor()).c_str());
@@ -1739,7 +1739,7 @@
   Class* super = klass->GetSuperClass();
   if (klass->GetDescriptor()->Equals("Ljava/lang/Object;")) {
     if (super != NULL) {
-      Thread::Current()->ThrowNewException("Ljava/lang/ClassFormatError;",
+      Thread::Current()->ThrowNewExceptionF("Ljava/lang/ClassFormatError;",
           "java.lang.Object must not have a superclass");
       return false;
     }
@@ -1753,7 +1753,7 @@
   }
   // Verify
   if (super->IsFinal() || super->IsInterface()) {
-    Thread::Current()->ThrowNewException("Ljava/lang/IncompatibleClassChangeError;",
+    Thread::Current()->ThrowNewExceptionF("Ljava/lang/IncompatibleClassChangeError;",
         "Superclass %s of %s is %s",
         PrettyDescriptor(super->GetDescriptor()).c_str(),
         PrettyDescriptor(klass->GetDescriptor()).c_str(),
@@ -1761,7 +1761,7 @@
     return false;
   }
   if (!klass->CanAccess(super)) {
-    Thread::Current()->ThrowNewException("Ljava/lang/IllegalAccessError;",
+    Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalAccessError;",
         "Superclass %s is inaccessible by %s",
         PrettyDescriptor(super->GetDescriptor()).c_str(),
         PrettyDescriptor(klass->GetDescriptor()).c_str());
@@ -1894,7 +1894,7 @@
     Class* interface = klass->GetInterface(i);
     DCHECK(interface != NULL);
     if (!interface->IsInterface()) {
-      Thread::Current()->ThrowNewException("Ljava/lang/IncompatibleClassChangeError;",
+      Thread::Current()->ThrowNewExceptionF("Ljava/lang/IncompatibleClassChangeError;",
           "Class %s implements non-interface class %s",
           PrettyDescriptor(klass->GetDescriptor()).c_str(),
           PrettyDescriptor(interface->GetDescriptor()).c_str());
@@ -1936,7 +1936,7 @@
         Method* vtable_method = vtable->Get(k);
         if (interface_method->HasSameNameAndDescriptor(vtable_method)) {
           if (!vtable_method->IsPublic()) {
-            Thread::Current()->ThrowNewException("Ljava/lang/IllegalAccessError;",
+            Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalAccessError;",
                 "Implementation not public: %s", PrettyMethod(vtable_method).c_str());
             return false;
           }
@@ -2250,7 +2250,7 @@
       Class* check = resolved->IsArrayClass() ? resolved->GetComponentType() : resolved;
       if (dex_cache != check->GetDexCache()) {
         if (check->GetClassLoader() != NULL) {
-          Thread::Current()->ThrowNewException("Ljava/lang/IllegalAccessError;",
+          Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalAccessError;",
               "Class with type index %d resolved by unexpected .dex", type_idx);
           resolved = NULL;
         }