Address review comments.
Change-Id: I93e1f3244babb6f7a809a5fbb8cb718f34ccf220
diff --git a/src/dalvik_system_DexFile.cc b/src/dalvik_system_DexFile.cc
index 85948f0..c009aba 100644
--- a/src/dalvik_system_DexFile.cc
+++ b/src/dalvik_system_DexFile.cc
@@ -183,24 +183,12 @@
class_linker->RegisterDexFile(*dex_file);
Class* result = class_linker->DefineClass(descriptor, class_loader, *dex_file, *dex_class_def);
if (env->ExceptionCheck()) {
- // Remember exception and clear it
+ // If we threw a ClassNotFoundException, stifle it, since the contract in the caller
+ // says we simply return null if the class is not found.
jthrowable exception = env->ExceptionOccurred();
env->ExceptionClear();
- // If we threw a "class not found" exception, stifle it, since the contract in the higher
- // method says we simply return null if the class is not found.
- static const char* ignored_exception_classes[] = {
- "java/lang/ClassNotFoundException",
-// "java/lang/NoClassDefFoundError"
- };
- bool clear_exception = false;
- for (size_t i = 0; i < arraysize(ignored_exception_classes); i++) {
- ScopedLocalRef<jclass> exception_class(env, env->FindClass(ignored_exception_classes[i]));
- if (env->IsInstanceOf(exception, exception_class.get())) {
- clear_exception = true;
- break;
- }
- }
- if (!clear_exception) {
+ ScopedLocalRef<jclass> exception_class(env, env->FindClass("java/lang/ClassNotFoundException"));
+ if (!env->IsInstanceOf(exception, exception_class.get())) {
env->Throw(exception);
}
return NULL;