changeset 9603:0e914bbdc744

8035750: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Dialog.cpp Reviewed-by: serb, pchelko
author azvegint
date Wed, 05 Mar 2014 16:36:49 +0400
parents 7dc85a81a8dd
children 50f46b8416bb
files src/windows/native/sun/windows/awt_Dialog.cpp
diffstat 1 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/native/sun/windows/awt_Dialog.cpp	Fri Apr 25 21:02:56 2014 +0400
+++ b/src/windows/native/sun/windows/awt_Dialog.cpp	Wed Mar 05 16:36:49 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
  * questions.
  */
 
+#include "jni_util.h"
 #include "awt_Toolkit.h"
 #include "awt_Dialog.h"
 #include "awt_Window.h"
@@ -457,18 +458,25 @@
 {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
-    jclass wwindowPeerCls = env->FindClass("sun/awt/windows/WWindowPeer");
-    jmethodID getActiveWindowsMID = env->GetStaticMethodID(wwindowPeerCls,
-                                                           "getActiveWindowHandles", "()[J");
-    DASSERT(getActiveWindowsMID != NULL);
-    jlongArray windows = (jlongArray)(env->CallStaticObjectMethod(wwindowPeerCls,
-                                                                  getActiveWindowsMID));
+    jboolean exc;
+    jlongArray windows = (jlongArray) JNU_CallStaticMethodByName
+                                            (env,
+                                             &exc,
+                                             "sun/awt/windows/WWindowPeer",
+                                             "getActiveWindowHandles",
+                                             "()[J").l;
+    if (exc == JNI_TRUE) {
+        throw std::bad_alloc();
+    }
     if (windows == NULL) {
         return;
     }
 
     jboolean isCopy;
     jlong *ws = env->GetLongArrayElements(windows, &isCopy);
+    if (ws == NULL) {
+        throw std::bad_alloc();
+    }
     int windowsCount = env->GetArrayLength(windows);
     for (int i = windowsCount - 1; i >= 0; i--) {
         HWND w = (HWND)ws[i];
@@ -744,11 +752,13 @@
     /* java.awt.Dialog fields and methods */
     AwtDialog::titleID
         = env->GetFieldID(cls, "title", "Ljava/lang/String;");
+    DASSERT(AwtDialog::titleID != NULL);
+    CHECK_NULL(AwtDialog::titleID);
+
     AwtDialog::undecoratedID
         = env->GetFieldID(cls,"undecorated","Z");
-
     DASSERT(AwtDialog::undecoratedID != NULL);
-    DASSERT(AwtDialog::titleID != NULL);
+    CHECK_NULL(AwtDialog::undecoratedID);
 
     CATCH_BAD_ALLOC;
 }