7045174: Most of the tests in awt area fails with jdk 7b142 on windows with -Xcheck:jni
authorbagiras
Fri, 27 May 2011 11:45:08 +0400
changeset 9763 7959b998d1ef
parent 9726 4a05062d8c4d
child 9764 2c32301ba9b8
7045174: Most of the tests in awt area fails with jdk 7b142 on windows with -Xcheck:jni Reviewed-by: art, denis
jdk/src/windows/native/sun/windows/awt_Object.cpp
jdk/src/windows/native/sun/windows/awt_Toolkit.cpp
--- a/jdk/src/windows/native/sun/windows/awt_Object.cpp	Wed Jul 05 17:45:01 2017 +0200
+++ b/jdk/src/windows/native/sun/windows/awt_Object.cpp	Fri May 27 11:45:08 2011 +0400
@@ -69,9 +69,12 @@
 
     CriticalSection::Lock l(AwtToolkit::GetInstance().GetSyncCS());
 
+    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+    jobject selfGlobalRef = env->NewGlobalRef(self);
+
     // value 0 of lParam means that we should not attempt to enter the
     // SyncCall critical section, as it was entered someshere earlier
-    AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)self, (LPARAM)0);
+    AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)selfGlobalRef, (LPARAM)0);
 
     CATCH_BAD_ALLOC;
 }
--- a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp	Wed Jul 05 17:45:01 2017 +0200
+++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp	Fri May 27 11:45:08 2011 +0400
@@ -741,7 +741,9 @@
           }
           if (canDispose) {
               if(wParam != NULL) {
-                  AwtObject *o = (AwtObject *) JNI_GET_PDATA((jobject)wParam);
+                  jobject self = (jobject)wParam;
+                  AwtObject *o = (AwtObject *) JNI_GET_PDATA(self);
+                  env->DeleteGlobalRef(self);
                   if(o != NULL && theAwtObjectList.Remove(o)) {
                       o->Dispose();
                   }