diff options
| author | 2011-11-23 13:23:23 -0500 | |
|---|---|---|
| committer | 2011-11-23 13:23:23 -0500 | |
| commit | 4ed21576f4ff58d37c872c4c790823d80d90d249 (patch) | |
| tree | 02bd0c4fb08e30c9114292a4cdccd47b9b338b6c /src/java_lang_Class.cc | |
| parent | 434424a3f60f2129aaa1780ac6a5c2618bc789e0 (diff) | |
Fix reflection to throw rather than crash when a type is not loaded.
This was caught by MissingClassesTest.
Change-Id: I719649c0efc5aceb1c4594cfa69f6a0d407fcacb
Diffstat (limited to 'src/java_lang_Class.cc')
| -rw-r--r-- | src/java_lang_Class.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/java_lang_Class.cc b/src/java_lang_Class.cc index f4376ec366..0ed6ceaad6 100644 --- a/src/java_lang_Class.cc +++ b/src/java_lang_Class.cc @@ -116,12 +116,18 @@ jobjectArray Class_getDeclaredFields(JNIEnv* env, jclass, jclass javaClass, jboo 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); } } 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); } @@ -147,12 +153,18 @@ jobjectArray Class_getDeclaredMethods(JNIEnv* env, jclass, jclass javaClass, jbo 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); } } 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); } |