Fixed DexFile.defineClass to return null, not throw Exception

Change-Id: I09e16d5530698b41f18ae33cca7745aa3d164922
diff --git a/src/dalvik_system_DexFile.cc b/src/dalvik_system_DexFile.cc
index 96b7817..67ff27f 100644
--- a/src/dalvik_system_DexFile.cc
+++ b/src/dalvik_system_DexFile.cc
@@ -124,8 +124,6 @@
   const std::string descriptor = DotToDescriptor(class_name.c_str());
   const DexFile::ClassDef* dex_class_def = dex_file->FindClassDef(descriptor);
   if (dex_class_def == NULL) {
-    jniThrowExceptionFmt(env, "java/lang/NoClassDefFoundError", "Class %s not found",
-                         class_name.c_str());
     return NULL;
   }
 
@@ -134,6 +132,10 @@
   ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
   class_linker->RegisterDexFile(*dex_file);
   Class* result = class_linker->DefineClass(descriptor, class_loader, *dex_file, *dex_class_def);
+  if (env->ExceptionCheck()) {
+    env->ExceptionClear();
+    return NULL;
+  }
   return AddLocalReference<jclass>(env, result);
 }