8036793: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_new.cpp
authorpchelko
Mon, 17 Mar 2014 13:03:39 +0400
changeset 23656 126ade88eb63
parent 23655 80eccae94bf6
child 23657 1bc509cbe2a3
8036793: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_new.cpp Reviewed-by: anthony, serb, azvegint
jdk/src/windows/native/sun/windows/awt_new.cpp
--- a/jdk/src/windows/native/sun/windows/awt_new.cpp	Fri Mar 14 19:27:40 2014 +0400
+++ b/jdk/src/windows/native/sun/windows/awt_new.cpp	Mon Mar 17 13:03:39 2014 +0400
@@ -163,18 +163,13 @@
 safe_ExceptionOccurred(JNIEnv *env) throw (std::bad_alloc) {
     jthrowable xcp = env->ExceptionOccurred();
     if (xcp != NULL) {
-        env->ExceptionClear(); // if we don't do this, FindClass will fail
-
-        jclass outofmem = env->FindClass("java/lang/OutOfMemoryError");
-        DASSERT(outofmem != NULL);
-        jboolean isOutofmem = env->IsInstanceOf(xcp, outofmem);
-
-        env->DeleteLocalRef(outofmem);
-
-        if (isOutofmem) {
+        env->ExceptionClear(); // if we don't do this, isInstanceOf will fail
+        jint isOutofmem = JNU_IsInstanceOfByName(env, xcp, "java/lang/OutOfMemoryError");
+        if (isOutofmem > 0) {
             env->DeleteLocalRef(xcp);
             throw std::bad_alloc();
         } else {
+            env->ExceptionClear();
             // rethrow exception
             env->Throw(xcp);
             return xcp;