@@ -116,7 +116,7 @@ - (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b {
116
116
AWT_ASSERT_APPKIT_THREAD;
117
117
118
118
JNIEnv *env = [ThreadUtilities getJNIEnv ];
119
- jobject platformWindow = [(( AWTWindow *)self .delegate).javaPlatformWindow jObjectWithEnv: env] ;
119
+ jobject platformWindow = (*env)-> NewLocalRef (env, (( AWTWindow *)self.delegate ).javaPlatformWindow ) ;
120
120
if (platformWindow != NULL ) {
121
121
// extract the target AWT Window object out of the CPlatformWindow
122
122
GET_CPLATFORM_WINDOW_CLASS ();
@@ -281,7 +281,7 @@ - (void) setPropertiesForStyleBits:(jint)bits mask:(jint)mask {
281
281
}
282
282
}
283
283
284
- - (id ) initWithPlatformWindow : (JNFWeakJObjectWrapper * )platformWindow
284
+ - (id ) initWithPlatformWindow : (jobject )platformWindow
285
285
ownerWindow :owner
286
286
styleBits : (jint)bits
287
287
frameRect : (NSRect )rect
@@ -482,7 +482,7 @@ - (void) dealloc {
482
482
AWT_ASSERT_APPKIT_THREAD;
483
483
484
484
JNIEnv *env = [ThreadUtilities getJNIEnvUncached ];
485
- [ self .javaPlatformWindow setJObject: nil withEnv: env] ;
485
+ (*env)-> DeleteWeakGlobalRef (env, self.javaPlatformWindow ) ;
486
486
self.javaPlatformWindow = nil ;
487
487
self.nsWindow = nil ;
488
488
self.ownerWindow = nil ;
@@ -494,7 +494,7 @@ - (BOOL) isBlocked {
494
494
BOOL isBlocked = NO ;
495
495
496
496
JNIEnv *env = [ThreadUtilities getJNIEnv ];
497
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
497
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
498
498
if (platformWindow != NULL ) {
499
499
GET_CPLATFORM_WINDOW_CLASS_RETURN (isBlocked);
500
500
DECLARE_METHOD_RETURN (jm_isBlocked, jc_CPlatformWindow, " isBlocked" , " ()Z" , isBlocked);
@@ -511,7 +511,7 @@ - (BOOL) isSimpleWindowOwnedByEmbeddedFrame {
511
511
BOOL isSimpleWindowOwnedByEmbeddedFrame = NO ;
512
512
513
513
JNIEnv *env = [ThreadUtilities getJNIEnv ];
514
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
514
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
515
515
if (platformWindow != NULL ) {
516
516
GET_CPLATFORM_WINDOW_CLASS_RETURN (NO );
517
517
DECLARE_METHOD_RETURN (jm_isBlocked, jc_CPlatformWindow, " isSimpleWindowOwnedByEmbeddedFrame" , " ()Z" , NO );
@@ -532,7 +532,7 @@ + (BOOL) isJavaPlatformWindowVisible:(NSWindow *)window {
532
532
[AWTToolkit eventCountPlusPlus ];
533
533
534
534
JNIEnv *env = [ThreadUtilities getJNIEnv ];
535
- jobject platformWindow = [ awtWindow.javaPlatformWindow jObjectWithEnv: env] ;
535
+ jobject platformWindow = (*env)-> NewLocalRef (env, awtWindow.javaPlatformWindow ) ;
536
536
if (platformWindow != NULL ) {
537
537
GET_CPLATFORM_WINDOW_CLASS_RETURN (isVisible);
538
538
DECLARE_METHOD_RETURN (jm_isVisible, jc_CPlatformWindow, " isVisible" , " ()Z" , isVisible)
@@ -603,7 +603,7 @@ - (BOOL) canBecomeMainWindow {
603
603
[AWTToolkit eventCountPlusPlus ];
604
604
605
605
JNIEnv *env = [ThreadUtilities getJNIEnv ];
606
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
606
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
607
607
if (platformWindow != NULL ) {
608
608
GET_CPLATFORM_WINDOW_CLASS_RETURN (NO );
609
609
DECLARE_METHOD_RETURN (jm_checkBlockingAndOrder, jc_CPlatformWindow, " checkBlockingAndOrder" , " ()Z" , NO );
@@ -632,7 +632,7 @@ - (void) _deliverMoveResizeEvent {
632
632
// the bounds of the window to avoid the Dock or remain on screen.
633
633
[AWTToolkit eventCountPlusPlus ];
634
634
JNIEnv *env = [ThreadUtilities getJNIEnv ];
635
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
635
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
636
636
if (platformWindow == NULL ) {
637
637
// TODO: create generic AWT assert
638
638
}
@@ -710,7 +710,7 @@ - (void) _deliverIconify:(BOOL)iconify {
710
710
711
711
[AWTToolkit eventCountPlusPlus ];
712
712
JNIEnv *env = [ThreadUtilities getJNIEnv ];
713
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
713
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
714
714
if (platformWindow != NULL ) {
715
715
GET_CPLATFORM_WINDOW_CLASS ();
716
716
DECLARE_METHOD (jm_deliverIconify, jc_CPlatformWindow, " deliverIconify" , " (Z)V" );
@@ -726,7 +726,7 @@ - (void)windowWillMiniaturize:(NSNotification *)notification {
726
726
self.isMinimizing = YES ;
727
727
728
728
JNIEnv *env = [ThreadUtilities getJNIEnv ];
729
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
729
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
730
730
if (platformWindow != NULL ) {
731
731
GET_CPLATFORM_WINDOW_CLASS ();
732
732
DECLARE_METHOD (jm_windowWillMiniaturize, jc_CPlatformWindow, " windowWillMiniaturize" , " ()V" );
@@ -757,9 +757,9 @@ - (void)windowDidDeminiaturize:(NSNotification *)notification {
757
757
- (void ) _deliverWindowFocusEvent : (BOOL )focused oppositeWindow : (AWTWindow *)opposite {
758
758
// AWT_ASSERT_APPKIT_THREAD;
759
759
JNIEnv *env = [ThreadUtilities getJNIEnvUncached ];
760
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
760
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
761
761
if (platformWindow != NULL ) {
762
- jobject oppositeWindow = [ opposite.javaPlatformWindow jObjectWithEnv: env] ;
762
+ jobject oppositeWindow = (*env)-> NewLocalRef (env, opposite.javaPlatformWindow ) ;
763
763
GET_CPLATFORM_WINDOW_CLASS ();
764
764
DECLARE_METHOD (jm_deliverWindowFocusEvent, jc_CPlatformWindow, " deliverWindowFocusEvent" , " (ZLsun/lwawt/macosx/CPlatformWindow;)V" );
765
765
(*env)->CallVoidMethod (env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
@@ -788,7 +788,7 @@ - (void) windowDidBecomeMain: (NSNotification *) notification {
788
788
}
789
789
790
790
JNIEnv *env = [ThreadUtilities getJNIEnv ];
791
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
791
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
792
792
if (platformWindow != NULL ) {
793
793
GET_CPLATFORM_WINDOW_CLASS ();
794
794
DECLARE_METHOD (jm_windowDidBecomeMain, jc_CPlatformWindow, " windowDidBecomeMain" , " ()V" );
@@ -904,7 +904,7 @@ - (BOOL)windowShouldClose:(id)sender {
904
904
AWT_ASSERT_APPKIT_THREAD;
905
905
[AWTToolkit eventCountPlusPlus ];
906
906
JNIEnv *env = [ThreadUtilities getJNIEnv ];
907
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
907
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
908
908
if (platformWindow != NULL ) {
909
909
GET_CPLATFORM_WINDOW_CLASS_RETURN (NO );
910
910
DECLARE_METHOD_RETURN (jm_deliverWindowClosingEvent, jc_CPlatformWindow, " deliverWindowClosingEvent" , " ()V" , NO );
@@ -922,7 +922,7 @@ - (void)_notifyFullScreenOp:(jint)op withEnv:(JNIEnv *)env {
922
922
" handleFullScreenEventFromNative" , " (Ljava/awt/Window;I)V" );
923
923
GET_CPLATFORM_WINDOW_CLASS ();
924
924
DECLARE_FIELD (jf_target, jc_CPlatformWindow, " target" , " Ljava/awt/Window;" );
925
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
925
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
926
926
if (platformWindow != NULL ) {
927
927
jobject awtWindow = (*env)->GetObjectField (env, platformWindow, jf_target);
928
928
if (awtWindow != NULL ) {
@@ -939,7 +939,7 @@ - (void)windowWillEnterFullScreen:(NSNotification *)notification {
939
939
JNIEnv *env = [ThreadUtilities getJNIEnv ];
940
940
GET_CPLATFORM_WINDOW_CLASS ();
941
941
DECLARE_METHOD (jm_windowWillEnterFullScreen, jc_CPlatformWindow, " windowWillEnterFullScreen" , " ()V" );
942
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
942
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
943
943
if (platformWindow != NULL ) {
944
944
(*env)->CallVoidMethod (env, platformWindow, jm_windowWillEnterFullScreen);
945
945
CHECK_EXCEPTION ();
@@ -952,7 +952,7 @@ - (void)windowDidEnterFullScreen:(NSNotification *)notification {
952
952
JNIEnv *env = [ThreadUtilities getJNIEnv ];
953
953
GET_CPLATFORM_WINDOW_CLASS ();
954
954
DECLARE_METHOD (jm_windowDidEnterFullScreen, jc_CPlatformWindow, " windowDidEnterFullScreen" , " ()V" );
955
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
955
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
956
956
if (platformWindow != NULL ) {
957
957
(*env)->CallVoidMethod (env, platformWindow, jm_windowDidEnterFullScreen);
958
958
CHECK_EXCEPTION ();
@@ -971,7 +971,7 @@ - (void)windowWillExitFullScreen:(NSNotification *)notification {
971
971
jm_windowWillExitFullScreen = (*env)->GetMethodID (env, jc_CPlatformWindow, " windowWillExitFullScreen" , " ()V" );
972
972
}
973
973
CHECK_NULL (jm_windowWillExitFullScreen);
974
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
974
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
975
975
if (platformWindow != NULL ) {
976
976
(*env)->CallVoidMethod (env, platformWindow, jm_windowWillExitFullScreen);
977
977
CHECK_EXCEPTION ();
@@ -982,7 +982,7 @@ - (void)windowWillExitFullScreen:(NSNotification *)notification {
982
982
983
983
- (void )windowDidExitFullScreen : (NSNotification *)notification {
984
984
JNIEnv *env = [ThreadUtilities getJNIEnv ];
985
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
985
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
986
986
if (platformWindow != NULL ) {
987
987
GET_CPLATFORM_WINDOW_CLASS ();
988
988
DECLARE_METHOD (jm_windowDidExitFullScreen, jc_CPlatformWindow, " windowDidExitFullScreen" , " ()V" );
@@ -1001,7 +1001,7 @@ - (void)sendEvent:(NSEvent *)event {
1001
1001
// in front of its nearest parent.
1002
1002
if (self.ownerWindow != nil ) {
1003
1003
JNIEnv *env = [ThreadUtilities getJNIEnvUncached ];
1004
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
1004
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
1005
1005
if (platformWindow != NULL ) {
1006
1006
GET_CPLATFORM_WINDOW_CLASS ();
1007
1007
DECLARE_METHOD (jm_orderAboveSiblings, jc_CPlatformWindow, " orderAboveSiblings" , " ()V" );
@@ -1020,7 +1020,7 @@ - (void)sendEvent:(NSEvent *)event {
1020
1020
// Check if the click happened in the non-client area (title bar)
1021
1021
if (p.y >= (frame.origin .y + contentRect.size .height )) {
1022
1022
JNIEnv *env = [ThreadUtilities getJNIEnvUncached ];
1023
- jobject platformWindow = [ self .javaPlatformWindow jObjectWithEnv: env] ;
1023
+ jobject platformWindow = (*env)-> NewLocalRef (env, self.javaPlatformWindow ) ;
1024
1024
if (platformWindow != NULL ) {
1025
1025
// Currently, no need to deliver the whole NSEvent.
1026
1026
GET_CPLATFORM_WINDOW_CLASS ();
@@ -1103,7 +1103,7 @@ + (AWTWindow *) lastKeyWindow {
1103
1103
1104
1104
JNI_COCOA_ENTER (env);
1105
1105
1106
- JNFWeakJObjectWrapper * platformWindow = [JNFWeakJObjectWrapper wrapperWithJObject: obj withEnv: env] ;
1106
+ jobject platformWindow = (*env)-> NewWeakGlobalRef (env, obj) ;
1107
1107
NSView *contentView = OBJC (contentViewPtr);
1108
1108
NSRect frameRect = NSMakeRect (x, y, w, h);
1109
1109
AWTWindow *owner = [OBJC (ownerPtr) delegate ];
@@ -1544,7 +1544,7 @@ + (AWTWindow *) lastKeyWindow {
1544
1544
[ThreadUtilities performOnMainThreadWaiting: YES block: ^{
1545
1545
AWTWindow *awtWindow = [AWTWindow getTopmostWindowUnderMouse ];
1546
1546
if (awtWindow != nil ) {
1547
- topmostWindowUnderMouse = [ awtWindow.javaPlatformWindow jObject ] ;
1547
+ topmostWindowUnderMouse = awtWindow.javaPlatformWindow ;
1548
1548
}
1549
1549
}];
1550
1550
0 commit comments