Move the exception check to after the code that throws the exception.

I'd mistakenly put the exception check after the method lookup,
but the exception was actually thrown by IsVisibleField(). The
test passed because this class had multiple fields to initialize.

Change-Id: I7c76abfad5d90cc36cb4fadedeb6628ca51ed433
diff --git a/src/java_lang_Class.cc b/src/java_lang_Class.cc
index 0ed6cea..9d48ede 100644
--- a/src/java_lang_Class.cc
+++ b/src/java_lang_Class.cc
@@ -116,21 +116,21 @@
   std::vector<Field*> fields;
   for (size_t i = 0; i < c->NumInstanceFields(); ++i) {
     Field* f = c->GetInstanceField(i);
-    if (env->ExceptionOccurred()) {
-      return NULL;
-    }
     if (IsVisibleField(f, publicOnly)) {
       fields.push_back(f);
     }
+    if (env->ExceptionOccurred()) {
+      return NULL;
+    }
   }
   for (size_t i = 0; i < c->NumStaticFields(); ++i) {
     Field* f = c->GetStaticField(i);
-    if (env->ExceptionOccurred()) {
-      return NULL;
-    }
     if (IsVisibleField(f, publicOnly)) {
       fields.push_back(f);
     }
+    if (env->ExceptionOccurred()) {
+      return NULL;
+    }
   }
 
   return ToArray(env, "java/lang/reflect/Field", fields);
@@ -153,21 +153,21 @@
   std::vector<Method*> methods;
   for (size_t i = 0; i < c->NumVirtualMethods(); ++i) {
     Method* m = c->GetVirtualMethod(i);
-    if (env->ExceptionOccurred()) {
-      return NULL;
-    }
     if (IsVisibleMethod(m, publicOnly)) {
       methods.push_back(m);
     }
+    if (env->ExceptionOccurred()) {
+      return NULL;
+    }
   }
   for (size_t i = 0; i < c->NumDirectMethods(); ++i) {
     Method* m = c->GetDirectMethod(i);
-    if (env->ExceptionOccurred()) {
-      return NULL;
-    }
     if (IsVisibleMethod(m, publicOnly)) {
       methods.push_back(m);
     }
+    if (env->ExceptionOccurred()) {
+      return NULL;
+    }
   }
 
   return ToArray(env, "java/lang/reflect/Method", methods);