DO NOT MERGE Fix all unsafe caching to be like libcore.

This way, if a runtime is restarted within a process, we re-initialize all
the cached data.

Conflicts:

	src/native/java_lang_Runtime.cc -- nativeExit lost an argument in dalvik-dev

(cherry picked from commit 7756d5473fa27ce7e6ac7c31770eef7030431da4)

Change-Id: I6184fc20c2a9ec16c4b053584a4d1c3b64452d0f
diff --git a/src/reflection.cc b/src/reflection.cc
index 010211e..2b72944 100644
--- a/src/reflection.cc
+++ b/src/reflection.cc
@@ -21,8 +21,6 @@
 #include "object.h"
 #include "object_utils.h"
 
-#include "JniConstants.h" // Last to avoid problems with LOG redefinition.
-
 namespace art {
 
 Method* gBoolean_valueOf;
@@ -62,7 +60,7 @@
   if (!m->IsStatic()) {
     // Check that the receiver is non-null and an instance of the field's declaring class.
     receiver = Decode<Object*>(env, javaReceiver);
-    if (!VerifyObjectInClass(env, receiver, declaring_class)) {
+    if (!VerifyObjectInClass(receiver, declaring_class)) {
       return NULL;
     }
 
@@ -117,18 +115,18 @@
   return AddLocalReference<jobject>(env, value.GetL());
 }
 
-bool VerifyObjectInClass(JNIEnv* env, Object* o, Class* c) {
+bool VerifyObjectInClass(Object* o, Class* c) {
   const char* exception = NULL;
   if (o == NULL) {
-    exception = "java/lang/NullPointerException";
+    exception = "Ljava/lang/NullPointerException;";
   } else if (!o->InstanceOf(c)) {
-    exception = "java/lang/IllegalArgumentException";
+    exception = "Ljava/lang/IllegalArgumentException;";
   }
   if (exception != NULL) {
     std::string expected_class_name(PrettyDescriptor(c));
     std::string actual_class_name(PrettyTypeOf(o));
-    jniThrowExceptionFmt(env, exception, "expected receiver of type %s, but got %s",
-                         expected_class_name.c_str(), actual_class_name.c_str());
+    Thread::Current()->ThrowNewExceptionF(exception, "expected receiver of type %s, but got %s",
+                                          expected_class_name.c_str(), actual_class_name.c_str());
     return false;
   }
   return true;