8156116: [macosx] two JNI locals to delete in AWTWindow.m, CGraphicsEnv.m
authorant
Fri, 20 May 2016 15:48:50 +0300
changeset 38987 ffe8b158dd6a
parent 38986 5b96e2b155eb
child 38988 ee7553e41c95
8156116: [macosx] two JNI locals to delete in AWTWindow.m, CGraphicsEnv.m Reviewed-by: serb, azvegint
jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Fri May 20 10:48:48 2016 +0300
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Fri May 20 15:48:50 2016 +0300
@@ -811,9 +811,12 @@
             if (p.y >= (frame.origin.y + contentRect.size.height)) {
                 JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
                 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
-                // Currently, no need to deliver the whole NSEvent.
-                static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V");
-                JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown);
+                if (platformWindow != NULL) {
+                    // Currently, no need to deliver the whole NSEvent.
+                    static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V");
+                    JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown);
+                    (*env)->DeleteLocalRef(env, platformWindow);
+                }
             }
         }
 }
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m	Fri May 20 10:48:48 2016 +0300
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m	Fri May 20 15:48:50 2016 +0300
@@ -127,6 +127,7 @@
                     jc_CGraphicsEnvironment, "_displayReconfiguration","(IZ)V");
             JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration,
                     (jint) display, (jboolean) flags & kCGDisplayRemoveFlag);
+            (*env)->DeleteLocalRef(env, graphicsEnv);
         });
     }];
 }