Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
8259869: [macOS] Remove desktop module dependencies on JNF Reference …
Browse files Browse the repository at this point in the history
…APIs

Backport-of: 92c2f08
  • Loading branch information
Vladimir Kempik committed Apr 8, 2021
1 parent 47ec3b8 commit df2818b
Show file tree
Hide file tree
Showing 21 changed files with 146 additions and 134 deletions.
11 changes: 4 additions & 7 deletions src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m
Expand Up @@ -121,7 +121,7 @@ - (void) dealloc {
{ {
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; JNIEnv *env = [ThreadUtilities getJNIEnvUncached];


JNFDeleteGlobalRef(env, fInputMethodLOCKABLE); (*env)->DeleteGlobalRef(env, fInputMethodLOCKABLE);
fInputMethodLOCKABLE = NULL; fInputMethodLOCKABLE = NULL;
} }


Expand Down Expand Up @@ -1363,14 +1363,10 @@ - (void)setInputMethod:(jobject)inputMethod


// Get rid of the old one // Get rid of the old one
if (fInputMethodLOCKABLE) { if (fInputMethodLOCKABLE) {
JNFDeleteGlobalRef(env, fInputMethodLOCKABLE); (*env)->DeleteGlobalRef(env, fInputMethodLOCKABLE);
} }


// Save a global ref to the new input method. fInputMethodLOCKABLE = inputMethod; // input method arg must be a GlobalRef
if (inputMethod != NULL)
fInputMethodLOCKABLE = JNFNewGlobalRef(env, inputMethod);
else
fInputMethodLOCKABLE = NULL;


NSTextInputContext *curContxt = [NSTextInputContext currentInputContext]; NSTextInputContext *curContxt = [NSTextInputContext currentInputContext];
kbdLayout = curContxt.selectedKeyboardInputSource; kbdLayout = curContxt.selectedKeyboardInputSource;
Expand Down Expand Up @@ -1412,6 +1408,7 @@ - (void)abandonInput


NSRect rect = NSMakeRect(originX, originY, width, height); NSRect rect = NSMakeRect(originX, originY, width, height);
jobject cPlatformView = (*env)->NewWeakGlobalRef(env, obj); jobject cPlatformView = (*env)->NewWeakGlobalRef(env, obj);
CHECK_EXCEPTION();


[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [ThreadUtilities performOnMainThreadWaiting:YES block:^(){


Expand Down
7 changes: 3 additions & 4 deletions src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h
Expand Up @@ -32,11 +32,10 @@
#import "LWCToolkit.h" #import "LWCToolkit.h"


@class AWTView; @class AWTView;
@class JNFWeakJObjectWrapper;


@interface AWTWindow : NSObject <NSWindowDelegate> { @interface AWTWindow : NSObject <NSWindowDelegate> {
@private @private
JNFWeakJObjectWrapper *javaPlatformWindow; jobject javaPlatformWindow; /* This is a weak ref. Always copy to a local ref before using */
CMenuBar *javaMenuBar; CMenuBar *javaMenuBar;
NSSize javaMinSize; NSSize javaMinSize;
NSSize javaMaxSize; NSSize javaMaxSize;
Expand All @@ -53,7 +52,7 @@
// An instance of either AWTWindow_Normal or AWTWindow_Panel // An instance of either AWTWindow_Normal or AWTWindow_Panel
@property (nonatomic, retain) NSWindow *nsWindow; @property (nonatomic, retain) NSWindow *nsWindow;


@property (nonatomic, retain) JNFWeakJObjectWrapper *javaPlatformWindow; @property (nonatomic) jobject javaPlatformWindow;
@property (nonatomic, retain) CMenuBar *javaMenuBar; @property (nonatomic, retain) CMenuBar *javaMenuBar;
@property (nonatomic, retain) AWTWindow *ownerWindow; @property (nonatomic, retain) AWTWindow *ownerWindow;
@property (nonatomic) NSSize javaMinSize; @property (nonatomic) NSSize javaMinSize;
Expand All @@ -65,7 +64,7 @@
@property (nonatomic) BOOL isMinimizing; @property (nonatomic) BOOL isMinimizing;
@property (nonatomic) BOOL keyNotificationRecd; @property (nonatomic) BOOL keyNotificationRecd;


- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)javaPlatformWindow - (id) initWithPlatformWindow:(jobject)javaPlatformWindow
ownerWindow:owner ownerWindow:owner
styleBits:(jint)styleBits styleBits:(jint)styleBits
frameRect:(NSRect)frameRect frameRect:(NSRect)frameRect
Expand Down
46 changes: 23 additions & 23 deletions src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
Expand Up @@ -116,7 +116,7 @@ - (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b {
AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD;


JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [((AWTWindow *)self.delegate).javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, ((AWTWindow *)self.delegate).javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
// extract the target AWT Window object out of the CPlatformWindow // extract the target AWT Window object out of the CPlatformWindow
GET_CPLATFORM_WINDOW_CLASS(); GET_CPLATFORM_WINDOW_CLASS();
Expand Down Expand Up @@ -281,7 +281,7 @@ - (void) setPropertiesForStyleBits:(jint)bits mask:(jint)mask {
} }
} }


- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow - (id) initWithPlatformWindow:(jobject)platformWindow
ownerWindow:owner ownerWindow:owner
styleBits:(jint)bits styleBits:(jint)bits
frameRect:(NSRect)rect frameRect:(NSRect)rect
Expand Down Expand Up @@ -482,7 +482,7 @@ - (void) dealloc {
AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD;


JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
[self.javaPlatformWindow setJObject:nil withEnv:env]; (*env)->DeleteWeakGlobalRef(env, self.javaPlatformWindow);
self.javaPlatformWindow = nil; self.javaPlatformWindow = nil;
self.nsWindow = nil; self.nsWindow = nil;
self.ownerWindow = nil; self.ownerWindow = nil;
Expand All @@ -494,7 +494,7 @@ - (BOOL) isBlocked {
BOOL isBlocked = NO; BOOL isBlocked = NO;


JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
GET_CPLATFORM_WINDOW_CLASS_RETURN(isBlocked); GET_CPLATFORM_WINDOW_CLASS_RETURN(isBlocked);
DECLARE_METHOD_RETURN(jm_isBlocked, jc_CPlatformWindow, "isBlocked", "()Z", isBlocked); DECLARE_METHOD_RETURN(jm_isBlocked, jc_CPlatformWindow, "isBlocked", "()Z", isBlocked);
Expand All @@ -511,7 +511,7 @@ - (BOOL) isSimpleWindowOwnedByEmbeddedFrame {
BOOL isSimpleWindowOwnedByEmbeddedFrame = NO; BOOL isSimpleWindowOwnedByEmbeddedFrame = NO;


JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
GET_CPLATFORM_WINDOW_CLASS_RETURN(NO); GET_CPLATFORM_WINDOW_CLASS_RETURN(NO);
DECLARE_METHOD_RETURN(jm_isBlocked, jc_CPlatformWindow, "isSimpleWindowOwnedByEmbeddedFrame", "()Z", NO); DECLARE_METHOD_RETURN(jm_isBlocked, jc_CPlatformWindow, "isSimpleWindowOwnedByEmbeddedFrame", "()Z", NO);
Expand All @@ -532,7 +532,7 @@ + (BOOL) isJavaPlatformWindowVisible:(NSWindow *)window {
[AWTToolkit eventCountPlusPlus]; [AWTToolkit eventCountPlusPlus];


JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [awtWindow.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, awtWindow.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
GET_CPLATFORM_WINDOW_CLASS_RETURN(isVisible); GET_CPLATFORM_WINDOW_CLASS_RETURN(isVisible);
DECLARE_METHOD_RETURN(jm_isVisible, jc_CPlatformWindow, "isVisible", "()Z", isVisible) DECLARE_METHOD_RETURN(jm_isVisible, jc_CPlatformWindow, "isVisible", "()Z", isVisible)
Expand Down Expand Up @@ -603,7 +603,7 @@ - (BOOL) canBecomeMainWindow {
[AWTToolkit eventCountPlusPlus]; [AWTToolkit eventCountPlusPlus];


JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
GET_CPLATFORM_WINDOW_CLASS_RETURN(NO); GET_CPLATFORM_WINDOW_CLASS_RETURN(NO);
DECLARE_METHOD_RETURN(jm_checkBlockingAndOrder, jc_CPlatformWindow, "checkBlockingAndOrder", "()Z", NO); DECLARE_METHOD_RETURN(jm_checkBlockingAndOrder, jc_CPlatformWindow, "checkBlockingAndOrder", "()Z", NO);
Expand Down Expand Up @@ -632,7 +632,7 @@ - (void) _deliverMoveResizeEvent {
// the bounds of the window to avoid the Dock or remain on screen. // the bounds of the window to avoid the Dock or remain on screen.
[AWTToolkit eventCountPlusPlus]; [AWTToolkit eventCountPlusPlus];
JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow == NULL) { if (platformWindow == NULL) {
// TODO: create generic AWT assert // TODO: create generic AWT assert
} }
Expand Down Expand Up @@ -710,7 +710,7 @@ - (void) _deliverIconify:(BOOL)iconify {


[AWTToolkit eventCountPlusPlus]; [AWTToolkit eventCountPlusPlus];
JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
GET_CPLATFORM_WINDOW_CLASS(); GET_CPLATFORM_WINDOW_CLASS();
DECLARE_METHOD(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V"); DECLARE_METHOD(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V");
Expand All @@ -726,7 +726,7 @@ - (void)windowWillMiniaturize:(NSNotification *)notification {
self.isMinimizing = YES; self.isMinimizing = YES;


JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
GET_CPLATFORM_WINDOW_CLASS(); GET_CPLATFORM_WINDOW_CLASS();
DECLARE_METHOD(jm_windowWillMiniaturize, jc_CPlatformWindow, "windowWillMiniaturize", "()V"); DECLARE_METHOD(jm_windowWillMiniaturize, jc_CPlatformWindow, "windowWillMiniaturize", "()V");
Expand Down Expand Up @@ -757,9 +757,9 @@ - (void)windowDidDeminiaturize:(NSNotification *)notification {
- (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite { - (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite {
//AWT_ASSERT_APPKIT_THREAD; //AWT_ASSERT_APPKIT_THREAD;
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
jobject oppositeWindow = [opposite.javaPlatformWindow jObjectWithEnv:env]; jobject oppositeWindow = (*env)->NewLocalRef(env, opposite.javaPlatformWindow);
GET_CPLATFORM_WINDOW_CLASS(); GET_CPLATFORM_WINDOW_CLASS();
DECLARE_METHOD(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V"); DECLARE_METHOD(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V");
(*env)->CallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow); (*env)->CallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
Expand Down Expand Up @@ -788,7 +788,7 @@ - (void) windowDidBecomeMain: (NSNotification *) notification {
} }


JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
GET_CPLATFORM_WINDOW_CLASS(); GET_CPLATFORM_WINDOW_CLASS();
DECLARE_METHOD(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V"); DECLARE_METHOD(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V");
Expand Down Expand Up @@ -904,7 +904,7 @@ - (BOOL)windowShouldClose:(id)sender {
AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD;
[AWTToolkit eventCountPlusPlus]; [AWTToolkit eventCountPlusPlus];
JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
GET_CPLATFORM_WINDOW_CLASS_RETURN(NO); GET_CPLATFORM_WINDOW_CLASS_RETURN(NO);
DECLARE_METHOD_RETURN(jm_deliverWindowClosingEvent, jc_CPlatformWindow, "deliverWindowClosingEvent", "()V", NO); DECLARE_METHOD_RETURN(jm_deliverWindowClosingEvent, jc_CPlatformWindow, "deliverWindowClosingEvent", "()V", NO);
Expand All @@ -922,7 +922,7 @@ - (void)_notifyFullScreenOp:(jint)op withEnv:(JNIEnv *)env {
"handleFullScreenEventFromNative", "(Ljava/awt/Window;I)V"); "handleFullScreenEventFromNative", "(Ljava/awt/Window;I)V");
GET_CPLATFORM_WINDOW_CLASS(); GET_CPLATFORM_WINDOW_CLASS();
DECLARE_FIELD(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;"); DECLARE_FIELD(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
jobject awtWindow = (*env)->GetObjectField(env, platformWindow, jf_target); jobject awtWindow = (*env)->GetObjectField(env, platformWindow, jf_target);
if (awtWindow != NULL) { if (awtWindow != NULL) {
Expand All @@ -939,7 +939,7 @@ - (void)windowWillEnterFullScreen:(NSNotification *)notification {
JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
GET_CPLATFORM_WINDOW_CLASS(); GET_CPLATFORM_WINDOW_CLASS();
DECLARE_METHOD(jm_windowWillEnterFullScreen, jc_CPlatformWindow, "windowWillEnterFullScreen", "()V"); DECLARE_METHOD(jm_windowWillEnterFullScreen, jc_CPlatformWindow, "windowWillEnterFullScreen", "()V");
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
(*env)->CallVoidMethod(env, platformWindow, jm_windowWillEnterFullScreen); (*env)->CallVoidMethod(env, platformWindow, jm_windowWillEnterFullScreen);
CHECK_EXCEPTION(); CHECK_EXCEPTION();
Expand All @@ -952,7 +952,7 @@ - (void)windowDidEnterFullScreen:(NSNotification *)notification {
JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
GET_CPLATFORM_WINDOW_CLASS(); GET_CPLATFORM_WINDOW_CLASS();
DECLARE_METHOD(jm_windowDidEnterFullScreen, jc_CPlatformWindow, "windowDidEnterFullScreen", "()V"); DECLARE_METHOD(jm_windowDidEnterFullScreen, jc_CPlatformWindow, "windowDidEnterFullScreen", "()V");
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
(*env)->CallVoidMethod(env, platformWindow, jm_windowDidEnterFullScreen); (*env)->CallVoidMethod(env, platformWindow, jm_windowDidEnterFullScreen);
CHECK_EXCEPTION(); CHECK_EXCEPTION();
Expand All @@ -971,7 +971,7 @@ - (void)windowWillExitFullScreen:(NSNotification *)notification {
jm_windowWillExitFullScreen = (*env)->GetMethodID(env, jc_CPlatformWindow, "windowWillExitFullScreen", "()V"); jm_windowWillExitFullScreen = (*env)->GetMethodID(env, jc_CPlatformWindow, "windowWillExitFullScreen", "()V");
} }
CHECK_NULL(jm_windowWillExitFullScreen); CHECK_NULL(jm_windowWillExitFullScreen);
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
(*env)->CallVoidMethod(env, platformWindow, jm_windowWillExitFullScreen); (*env)->CallVoidMethod(env, platformWindow, jm_windowWillExitFullScreen);
CHECK_EXCEPTION(); CHECK_EXCEPTION();
Expand All @@ -982,7 +982,7 @@ - (void)windowWillExitFullScreen:(NSNotification *)notification {


- (void)windowDidExitFullScreen:(NSNotification *)notification { - (void)windowDidExitFullScreen:(NSNotification *)notification {
JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
GET_CPLATFORM_WINDOW_CLASS(); GET_CPLATFORM_WINDOW_CLASS();
DECLARE_METHOD(jm_windowDidExitFullScreen, jc_CPlatformWindow, "windowDidExitFullScreen", "()V"); DECLARE_METHOD(jm_windowDidExitFullScreen, jc_CPlatformWindow, "windowDidExitFullScreen", "()V");
Expand All @@ -1001,7 +1001,7 @@ - (void)sendEvent:(NSEvent *)event {
// in front of its nearest parent. // in front of its nearest parent.
if (self.ownerWindow != nil) { if (self.ownerWindow != nil) {
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
GET_CPLATFORM_WINDOW_CLASS(); GET_CPLATFORM_WINDOW_CLASS();
DECLARE_METHOD(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V"); DECLARE_METHOD(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V");
Expand All @@ -1020,7 +1020,7 @@ - (void)sendEvent:(NSEvent *)event {
// Check if the click happened in the non-client area (title bar) // Check if the click happened in the non-client area (title bar)
if (p.y >= (frame.origin.y + contentRect.size.height)) { if (p.y >= (frame.origin.y + contentRect.size.height)) {
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
if (platformWindow != NULL) { if (platformWindow != NULL) {
// Currently, no need to deliver the whole NSEvent. // Currently, no need to deliver the whole NSEvent.
GET_CPLATFORM_WINDOW_CLASS(); GET_CPLATFORM_WINDOW_CLASS();
Expand Down Expand Up @@ -1103,7 +1103,7 @@ + (AWTWindow *) lastKeyWindow {


JNI_COCOA_ENTER(env); JNI_COCOA_ENTER(env);


JNFWeakJObjectWrapper *platformWindow = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env]; jobject platformWindow = (*env)->NewWeakGlobalRef(env, obj);
NSView *contentView = OBJC(contentViewPtr); NSView *contentView = OBJC(contentViewPtr);
NSRect frameRect = NSMakeRect(x, y, w, h); NSRect frameRect = NSMakeRect(x, y, w, h);
AWTWindow *owner = [OBJC(ownerPtr) delegate]; AWTWindow *owner = [OBJC(ownerPtr) delegate];
Expand Down Expand Up @@ -1544,7 +1544,7 @@ + (AWTWindow *) lastKeyWindow {
[ThreadUtilities performOnMainThreadWaiting:YES block:^{ [ThreadUtilities performOnMainThreadWaiting:YES block:^{
AWTWindow *awtWindow = [AWTWindow getTopmostWindowUnderMouse]; AWTWindow *awtWindow = [AWTWindow getTopmostWindowUnderMouse];
if (awtWindow != nil) { if (awtWindow != nil) {
topmostWindowUnderMouse = [awtWindow.javaPlatformWindow jObject]; topmostWindowUnderMouse = awtWindow.javaPlatformWindow;
} }
}]; }];


Expand Down
6 changes: 3 additions & 3 deletions src/java.desktop/macosx/native/libawt_lwawt/awt/CClipboard.m
Expand Up @@ -66,9 +66,9 @@ - (void)declareTypes:(NSArray*)types withOwner:(jobject)owner jniEnv:(JNIEnv*)en
@synchronized(self) { @synchronized(self) {
if (owner != NULL) { if (owner != NULL) {
if (self.clipboardOwner != NULL) { if (self.clipboardOwner != NULL) {
JNFDeleteGlobalRef(env, self.clipboardOwner); (*env)->DeleteGlobalRef(env, self.clipboardOwner);
} }
self.clipboardOwner = JNFNewGlobalRef(env, owner); self.clipboardOwner = (*env)->NewGlobalRef(env, owner);
} }
} }
[ThreadUtilities performOnMainThreadWaiting:YES block:^() { [ThreadUtilities performOnMainThreadWaiting:YES block:^() {
Expand Down Expand Up @@ -101,7 +101,7 @@ - (void)checkPasteboard:(id)sender {
if (self.clipboardOwner) { if (self.clipboardOwner) {
(*env)->CallVoidMethod(env, self.clipboardOwner, jm_lostOwnership); // AWT_THREADING Safe (event) (*env)->CallVoidMethod(env, self.clipboardOwner, jm_lostOwnership); // AWT_THREADING Safe (event)
CHECK_EXCEPTION(); CHECK_EXCEPTION();
JNFDeleteGlobalRef(env, self.clipboardOwner); (*env)->DeleteGlobalRef(env, self.clipboardOwner);
self.clipboardOwner = NULL; self.clipboardOwner = NULL;
} }
} }
Expand Down
12 changes: 6 additions & 6 deletions src/java.desktop/macosx/native/libawt_lwawt/awt/CDragSource.m
Expand Up @@ -169,32 +169,32 @@ - (void)removeFromView:(JNIEnv *)env


// Clean up JNI refs // Clean up JNI refs
if (fComponent != NULL) { if (fComponent != NULL) {
JNFDeleteGlobalRef(env, fComponent); (*env)->DeleteGlobalRef(env, fComponent);
fComponent = NULL; fComponent = NULL;
} }


if (fDragSourceContextPeer != NULL) { if (fDragSourceContextPeer != NULL) {
JNFDeleteGlobalRef(env, fDragSourceContextPeer); (*env)->DeleteGlobalRef(env, fDragSourceContextPeer);
fDragSourceContextPeer = NULL; fDragSourceContextPeer = NULL;
} }


if (fTransferable != NULL) { if (fTransferable != NULL) {
JNFDeleteGlobalRef(env, fTransferable); (*env)->DeleteGlobalRef(env, fTransferable);
fTransferable = NULL; fTransferable = NULL;
} }


if (fTriggerEvent != NULL) { if (fTriggerEvent != NULL) {
JNFDeleteGlobalRef(env, fTriggerEvent); (*env)->DeleteGlobalRef(env, fTriggerEvent);
fTriggerEvent = NULL; fTriggerEvent = NULL;
} }


if (fFormats != NULL) { if (fFormats != NULL) {
JNFDeleteGlobalRef(env, fFormats); (*env)->DeleteGlobalRef(env, fFormats);
fFormats = NULL; fFormats = NULL;
} }


if (fFormatMap != NULL) { if (fFormatMap != NULL) {
JNFDeleteGlobalRef(env, fFormatMap); (*env)->DeleteGlobalRef(env, fFormatMap);
fFormatMap = NULL; fFormatMap = NULL;
} }


Expand Down
Expand Up @@ -50,12 +50,12 @@
JNI_COCOA_ENTER(env); JNI_COCOA_ENTER(env);


// Global references are disposed when the DragSource is removed // Global references are disposed when the DragSource is removed
jobject gComponent = JNFNewGlobalRef(env, jcomponent); jobject gComponent = (*env)->NewGlobalRef(env, jcomponent);
jobject gDragSourceContextPeer = JNFNewGlobalRef(env, jthis); jobject gDragSourceContextPeer = (*env)->NewGlobalRef(env, jthis);
jobject gTransferable = JNFNewGlobalRef(env, jtransferable); jobject gTransferable = (*env)->NewGlobalRef(env, jtransferable);
jobject gTriggerEvent = JNFNewGlobalRef(env, jtrigger); jobject gTriggerEvent = (*env)->NewGlobalRef(env, jtrigger);
jlongArray gFormats = JNFNewGlobalRef(env, jformats); jlongArray gFormats = (*env)->NewGlobalRef(env, jformats);
jobject gFormatMap = JNFNewGlobalRef(env, jformatmap); jobject gFormatMap = (*env)->NewGlobalRef(env, jformatmap);


[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
dragSource = [[CDragSource alloc] init:gDragSourceContextPeer dragSource = [[CDragSource alloc] init:gDragSourceContextPeer
Expand Down

1 comment on commit df2818b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.