More tests for detail messages, plus a new one.

The array-length instruction is likely to encounter nulls.

Change-Id: I628f5f00dfaff9414740e2f7015b9fb3d34a1bc9
diff --git a/src/compiler.cc b/src/compiler.cc
index 4d98d61..aa465c3 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -245,9 +245,7 @@
   }
 
   // Capitalize the instruction set, because that's what we do in the build system.
-  std::ostringstream instruction_set_name_os;
-  instruction_set_name_os << instruction_set;
-  std::string instruction_set_name(instruction_set_name_os.str());
+  std::string instruction_set_name(ToStr<InstructionSet>(instruction_set).str());
   for (size_t i = 0; i < instruction_set_name.size(); ++i) {
     instruction_set_name[i] = toupper(instruction_set_name[i]);
   }
diff --git a/src/runtime_support.cc b/src/runtime_support.cc
index 903bbf9..06908c9 100644
--- a/src/runtime_support.cc
+++ b/src/runtime_support.cc
@@ -104,14 +104,12 @@
                                                       const Method* caller,
                                                       const Method* called,
                                                       InvokeType type) {
-  std::ostringstream type_stream;
-  type_stream << type;
   self->ThrowNewExceptionF("Ljava/lang/IllegalAccessError;",
                            "illegal class access ('%s' -> '%s')"
                            "in attempt to invoke %s method '%s' from '%s'",
                            PrettyDescriptor(referrer).c_str(),
                            PrettyDescriptor(accessed).c_str(),
-                           type_stream.str().c_str(),
+                           ToStr<InvokeType>(type).c_str(),
                            PrettyMethod(called).c_str(),
                            PrettyMethod(caller).c_str());
 }
@@ -169,11 +167,9 @@
                                               InvokeType type) {
   const DexFile& dex_file =
       Runtime::Current()->GetClassLinker()->FindDexFile(caller->GetDeclaringClass()->GetDexCache());
-  std::ostringstream type_stream;
-  type_stream << type;
   self->ThrowNewExceptionF("Ljava/lang/NullPointerException;",
                            "Attempt to invoke %s method '%s' on a null object reference",
-                           type_stream.str().c_str(),
+                           ToStr<InvokeType>(type).c_str(),
                            PrettyMethod(method_idx, dex_file, true).c_str());
 }
 
@@ -235,6 +231,10 @@
       self->ThrowNewException("Ljava/lang/NullPointerException;",
                               "Attempt to write to null array");
       break;
+    case Instruction::ARRAY_LENGTH:
+      self->ThrowNewException("Ljava/lang/NullPointerException;",
+                              "Attempt to get length of null array");
+      break;
     default: {
       const DexFile& dex_file = Runtime::Current()->GetClassLinker()
           ->FindDexFile(throw_method->GetDeclaringClass()->GetDexCache());