From 53494318448f783b89c20d7b42be7a608b168de1 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Tue, 29 Nov 2011 16:43:09 -0500 Subject: 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 --- src/java_lang_Class.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/java_lang_Class.cc') diff --git a/src/java_lang_Class.cc b/src/java_lang_Class.cc index 0ed6ceaad6..9d48edeb96 100644 --- a/src/java_lang_Class.cc +++ b/src/java_lang_Class.cc @@ -116,21 +116,21 @@ jobjectArray Class_getDeclaredFields(JNIEnv* env, jclass, jclass javaClass, jboo std::vector 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); } - } - for (size_t i = 0; i < c->NumStaticFields(); ++i) { - Field* f = c->GetStaticField(i); if (env->ExceptionOccurred()) { return NULL; } + } + for (size_t i = 0; i < c->NumStaticFields(); ++i) { + Field* f = c->GetStaticField(i); 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 @@ jobjectArray Class_getDeclaredMethods(JNIEnv* env, jclass, jclass javaClass, jbo std::vector 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); } - } - for (size_t i = 0; i < c->NumDirectMethods(); ++i) { - Method* m = c->GetDirectMethod(i); if (env->ExceptionOccurred()) { return NULL; } + } + for (size_t i = 0; i < c->NumDirectMethods(); ++i) { + Method* m = c->GetDirectMethod(i); if (IsVisibleMethod(m, publicOnly)) { methods.push_back(m); } + if (env->ExceptionOccurred()) { + return NULL; + } } return ToArray(env, "java/lang/reflect/Method", methods); -- cgit v1.2.3-59-g8ed1b