From 72344ee850e0fe8b3a7213c1cfc8db0d73f9c520 Mon Sep 17 00:00:00 2001 From: Petr Pchelko Date: Fri, 14 Mar 2014 16:01:04 +0400 Subject: [PATCH] 8037099: [macosx] Remove all references to GC from native OBJ-C code Reviewed-by: anthony, serb --- .../macosx/native/sun/awt/AWTSurfaceLayers.m | 4 +-- jdk/src/macosx/native/sun/awt/AWTView.m | 13 ++++---- jdk/src/macosx/native/sun/awt/AWTWindow.m | 2 +- .../native/sun/awt/ApplicationDelegate.m | 7 ++--- jdk/src/macosx/native/sun/awt/CClipboard.m | 1 - .../macosx/native/sun/awt/CDataTransferer.m | 2 -- jdk/src/macosx/native/sun/awt/CDesktopPeer.m | 2 +- jdk/src/macosx/native/sun/awt/CDragSource.m | 4 +-- .../native/sun/awt/CDragSourceContextPeer.m | 4 --- jdk/src/macosx/native/sun/awt/CDropTarget.m | 7 +---- jdk/src/macosx/native/sun/awt/CFileDialog.m | 7 ++--- jdk/src/macosx/native/sun/awt/CGraphicsEnv.m | 6 ++-- jdk/src/macosx/native/sun/awt/CImage.m | 28 +++++------------ jdk/src/macosx/native/sun/awt/CMenu.m | 17 ++--------- jdk/src/macosx/native/sun/awt/CMenuBar.m | 4 --- .../macosx/native/sun/awt/CMenuComponent.m | 6 +--- jdk/src/macosx/native/sun/awt/CMenuItem.m | 5 ---- jdk/src/macosx/native/sun/awt/CPopupMenu.m | 2 -- jdk/src/macosx/native/sun/awt/CPrinterJob.m | 4 +-- jdk/src/macosx/native/sun/awt/CSystemColors.m | 8 ++--- .../macosx/native/sun/awt/ImageSurfaceData.m | 2 +- .../native/sun/awt/JavaAccessibilityAction.m | 27 ----------------- .../sun/awt/JavaComponentAccessibility.m | 30 ++----------------- jdk/src/macosx/native/sun/awt/LWCToolkit.m | 21 +++++-------- jdk/src/macosx/native/sun/awt/PrintModel.m | 9 +++--- .../native/sun/osxapp/NSApplicationAWT.m | 1 - 26 files changed, 47 insertions(+), 176 deletions(-) diff --git a/jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.m b/jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.m index d12908c83a3..39fc4c2b82a 100644 --- a/jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.m +++ b/jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -103,8 +103,6 @@ JNF_COCOA_ENTER(env); CALayer *windowLayer = jlong_to_ptr(windowLayerPtr); surfaceLayers = [[AWTSurfaceLayers alloc] initWithWindowLayer: windowLayer]; - CFRetain(surfaceLayers); - [surfaceLayers release]; }]; JNF_COCOA_EXIT(env); diff --git a/jdk/src/macosx/native/sun/awt/AWTView.m b/jdk/src/macosx/native/sun/awt/AWTView.m index 1c8c4043404..bcc832190f4 100644 --- a/jdk/src/macosx/native/sun/awt/AWTView.m +++ b/jdk/src/macosx/native/sun/awt/AWTView.m @@ -112,9 +112,9 @@ AWT_ASSERT_APPKIT_THREAD; remoteLayer.parentLayer = parentLayer; remoteLayer.remoteLayer = NULL; remoteLayer.jrsRemoteLayer = [remoteLayer createRemoteLayerBoundTo:JRSRemotePort]; - CFRetain(remoteLayer); // REMIND + [remoteLayer retain]; // REMIND remoteLayer.frame = CGRectMake(0, 0, 720, 500); // REMIND - CFRetain(remoteLayer.jrsRemoteLayer); // REMIND + [remoteLayer.jrsRemoteLayer retain]; // REMIND int layerID = [remoteLayer.jrsRemoteLayer layerID]; NSLog(@"layer id to send = %d", layerID); sendLayerID(layerID); @@ -1275,12 +1275,9 @@ JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ CALayer *windowLayer = jlong_to_ptr(windowLayerPtr); - AWTView *view = [[AWTView alloc] initWithRect:rect - platformView:cPlatformView - windowLayer:windowLayer]; - CFRetain(view); - [view release]; // GC - newView = view; + newView = [[AWTView alloc] initWithRect:rect + platformView:cPlatformView + windowLayer:windowLayer]; }]; JNF_COCOA_EXIT(env); diff --git a/jdk/src/macosx/native/sun/awt/AWTWindow.m b/jdk/src/macosx/native/sun/awt/AWTWindow.m index f9a7919b4ef..df7b126e5e7 100644 --- a/jdk/src/macosx/native/sun/awt/AWTWindow.m +++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m @@ -791,7 +791,7 @@ JNF_COCOA_ENTER(env); contentView:contentView]; // the window is released is CPlatformWindow.nativeDispose() - if (window) CFRetain(window.nsWindow); + if (window) [window.nsWindow retain]; }]; JNF_COCOA_EXIT(env); diff --git a/jdk/src/macosx/native/sun/awt/ApplicationDelegate.m b/jdk/src/macosx/native/sun/awt/ApplicationDelegate.m index 81955757e4d..da48e7351dc 100644 --- a/jdk/src/macosx/native/sun/awt/ApplicationDelegate.m +++ b/jdk/src/macosx/native/sun/awt/ApplicationDelegate.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -255,8 +255,6 @@ AWT_ASSERT_APPKIT_THREAD; [super dealloc]; } -//- (void)finalize { [super finalize]; } // GC - #pragma mark Callbacks from AppKit @@ -623,8 +621,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeGetDockIc JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - image = [ApplicationDelegate _dockIconImage]; - CFRetain(image); + image = [[ApplicationDelegate _dockIconImage] retain]; }]; JNF_COCOA_EXIT(env); diff --git a/jdk/src/macosx/native/sun/awt/CClipboard.m b/jdk/src/macosx/native/sun/awt/CClipboard.m index 098e1c225ea..72e1cf4f0f8 100644 --- a/jdk/src/macosx/native/sun/awt/CClipboard.m +++ b/jdk/src/macosx/native/sun/awt/CClipboard.m @@ -72,7 +72,6 @@ static CClipboard *sClipboard = nil; [super dealloc]; } -//- (void)finalize { [super finalize]; } - (NSData *)data { return fData; diff --git a/jdk/src/macosx/native/sun/awt/CDataTransferer.m b/jdk/src/macosx/native/sun/awt/CDataTransferer.m index d648e924132..4fdefa47593 100644 --- a/jdk/src/macosx/native/sun/awt/CDataTransferer.m +++ b/jdk/src/macosx/native/sun/awt/CDataTransferer.m @@ -197,8 +197,6 @@ static jobject getImageForByteStream(JNIEnv *env, jbyteArray sourceData) NSData *rawData = [NSData dataWithBytes:sourceBytes length:sourceSize]; NSImage *newImage = [[NSImage alloc] initWithData:rawData]; - if (newImage) CFRetain(newImage); // GC - [newImage release]; (*env)->ReleasePrimitiveArrayCritical(env, sourceData, sourceBytes, JNI_ABORT); CHECK_NULL_RETURN(newImage, NULL); diff --git a/jdk/src/macosx/native/sun/awt/CDesktopPeer.m b/jdk/src/macosx/native/sun/awt/CDesktopPeer.m index ef9bdb6801b..9054da8ad65 100644 --- a/jdk/src/macosx/native/sun/awt/CDesktopPeer.m +++ b/jdk/src/macosx/native/sun/awt/CDesktopPeer.m @@ -79,7 +79,7 @@ JNF_COCOA_ENTER(env); LSApplicationParameters params = {0, flags, NULL, NULL, NULL, NULL, NULL}; status = LSOpenURLsWithRole((CFArrayRef)[NSArray arrayWithObject:url], kLSRolesAll, NULL, ¶ms, NULL, 0); - CFRelease(url); + [url release]; JNF_COCOA_EXIT(env); return status; diff --git a/jdk/src/macosx/native/sun/awt/CDragSource.m b/jdk/src/macosx/native/sun/awt/CDragSource.m index 992092a7a5d..c1e0571644a 100644 --- a/jdk/src/macosx/native/sun/awt/CDragSource.m +++ b/jdk/src/macosx/native/sun/awt/CDragSource.m @@ -188,7 +188,7 @@ static BOOL sNeedsEnter; fFormatMap = NULL; } - CFRelease(self); // GC + [self release]; } - (void)dealloc @@ -204,8 +204,6 @@ static BOOL sNeedsEnter; [super dealloc]; } -//- (void)finalize { [super finalize]; } - // Appropriated from Windows' awt_DataTransferer.cpp: // diff --git a/jdk/src/macosx/native/sun/awt/CDragSourceContextPeer.m b/jdk/src/macosx/native/sun/awt/CDragSourceContextPeer.m index 2b9f6e035dc..de0a49b236e 100644 --- a/jdk/src/macosx/native/sun/awt/CDragSourceContextPeer.m +++ b/jdk/src/macosx/native/sun/awt/CDragSourceContextPeer.m @@ -76,10 +76,6 @@ JNF_COCOA_ENTER(env); }]; JNF_COCOA_EXIT(env); - if (dragSource) { - CFRetain(dragSource); // GC - [dragSource release]; - } return ptr_to_jlong(dragSource); } diff --git a/jdk/src/macosx/native/sun/awt/CDropTarget.m b/jdk/src/macosx/native/sun/awt/CDropTarget.m index bff775fd10d..dcaf31c396e 100644 --- a/jdk/src/macosx/native/sun/awt/CDropTarget.m +++ b/jdk/src/macosx/native/sun/awt/CDropTarget.m @@ -169,7 +169,7 @@ extern JNFClassInfo jc_CDropTargetContextPeer; fDropTargetContextPeer = NULL; } - CFRelease(self); + [self release]; } - (void)dealloc @@ -185,7 +185,6 @@ extern JNFClassInfo jc_CDropTargetContextPeer; [super dealloc]; } -//- (void)finalize { [super finalize]; } - (NSInteger) getDraggingSequenceNumber { @@ -722,10 +721,6 @@ JNF_COCOA_ENTER(env); dropTarget = [[CDropTarget alloc] init:jdroptarget component:jcomponent peer:jpeer control:controlObj]; JNF_COCOA_EXIT(env); - if (dropTarget) { - CFRetain(dropTarget); // GC - [dropTarget release]; - } return ptr_to_jlong(dropTarget); } diff --git a/jdk/src/macosx/native/sun/awt/CFileDialog.m b/jdk/src/macosx/native/sun/awt/CFileDialog.m index 7dc820266c2..0a9621e9313 100644 --- a/jdk/src/macosx/native/sun/awt/CFileDialog.m +++ b/jdk/src/macosx/native/sun/awt/CFileDialog.m @@ -88,7 +88,6 @@ canChooseDirectories:(BOOL)inChooseDirectories [super dealloc]; } -//- (void)finalize { [super finalize]; } - (void)safeSaveOrLoad { NSSavePanel *thePanel = nil; @@ -168,9 +167,9 @@ canChooseDirectories:(BOOL)inChooseDirectories } // ask the file filter up in Java - CFStringRef filePath = CFURLCopyFileSystemPath((CFURLRef)url, kCFURLPOSIXPathStyle); - BOOL shouldEnableFile = [self askFilenameFilter:(NSString *)filePath]; - CFRelease(filePath); + NSString* filePath = (NSString*)CFURLCopyFileSystemPath((CFURLRef)url, kCFURLPOSIXPathStyle); + BOOL shouldEnableFile = [self askFilenameFilter:filePath]; + [filePath release]; return shouldEnableFile; } diff --git a/jdk/src/macosx/native/sun/awt/CGraphicsEnv.m b/jdk/src/macosx/native/sun/awt/CGraphicsEnv.m index dd36775ce31..72602b9eea8 100644 --- a/jdk/src/macosx/native/sun/awt/CGraphicsEnv.m +++ b/jdk/src/macosx/native/sun/awt/CGraphicsEnv.m @@ -145,8 +145,7 @@ Java_sun_awt_CGraphicsEnvironment_registerDisplayReconfiguration JNF_COCOA_ENTER(env); - JNFWeakJObjectWrapper *wrapper = [JNFWeakJObjectWrapper wrapperWithJObject:this withEnv:env]; - CFRetain(wrapper); // pin from ObjC-GC + JNFWeakJObjectWrapper *wrapper = [[JNFWeakJObjectWrapper wrapperWithJObject:this withEnv:env] retain]; /* Register the callback */ if (CGDisplayRegisterReconfigurationCallback(&displaycb_handle, wrapper) != kCGErrorSuccess) { @@ -186,8 +185,7 @@ JNF_COCOA_ENTER(env); } [wrapper setJObject:NULL withEnv:env]; // more efficiant to pre-clear - - CFRelease(wrapper); + [wrapper release]; JNF_COCOA_EXIT(env); } diff --git a/jdk/src/macosx/native/sun/awt/CImage.m b/jdk/src/macosx/native/sun/awt/CImage.m index a6b5e87ed42..abad7bde74e 100644 --- a/jdk/src/macosx/native/sun/awt/CImage.m +++ b/jdk/src/macosx/native/sun/awt/CImage.m @@ -115,14 +115,9 @@ JNF_COCOA_ENTER(env); NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height); if (imageRep) { - NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)]; + NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(width, height)] retain]; [nsImage addRepresentation:imageRep]; [imageRep release]; - - if (nsImage != nil) { - CFRetain(nsImage); // GC - } - result = ptr_to_jlong(nsImage); } @@ -165,13 +160,8 @@ JNF_COCOA_ENTER(env); (*env)->ReleaseIntArrayElements(env, widths, ws, JNI_ABORT); } if ([reps count]) { - NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0, 0)]; + NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(0, 0)] retain]; [nsImage addRepresentations: reps]; - - if (nsImage != nil) { - CFRetain(nsImage); // GC - } - result = ptr_to_jlong(nsImage); } @@ -194,8 +184,7 @@ JNF_COCOA_ENTER(env); IconRef iconRef; if (noErr == GetIconRef(kOnSystemDisk, kSystemIconsCreator, selector, &iconRef)) { - image = [[NSImage alloc] initWithIconRef:iconRef]; - if (image) CFRetain(image); // GC + image = [[[NSImage alloc] initWithIconRef:iconRef] retain]; ReleaseIconRef(iconRef); } @@ -217,8 +206,7 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromFile JNF_COCOA_ENTER(env); NSString *path = JNFNormalizedNSStringForPath(env, file); - image = [[NSImage alloc] initByReferencingFile:path]; - if (image) CFRetain(image); // GC + image = [[[NSImage alloc] initByReferencingFile:path] retain]; JNF_COCOA_EXIT(env); @@ -239,9 +227,8 @@ JNF_COCOA_ENTER(env); NSString *path = JNFNormalizedNSStringForPath(env, file); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - image = [[NSWorkspace sharedWorkspace] iconForFile:path]; + image = [[[NSWorkspace sharedWorkspace] iconForFile:path] retain]; [image setScalesWhenResized:TRUE]; - if (image) CFRetain(image); // GC }]; JNF_COCOA_EXIT(env); @@ -261,8 +248,7 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromImag JNF_COCOA_ENTER(env); - image = [NSImage imageNamed:JNFJavaToNSString(env, name)]; - if (image) CFRetain(image); // GC + image = [[NSImage imageNamed:JNFJavaToNSString(env, name)] retain]; JNF_COCOA_EXIT(env); @@ -435,4 +421,4 @@ JNF_COCOA_ENTER(env); JNF_COCOA_EXIT(env); return jreturnArray; -} \ No newline at end of file +} diff --git a/jdk/src/macosx/native/sun/awt/CMenu.m b/jdk/src/macosx/native/sun/awt/CMenu.m index e2db11c10fa..43b08f09d2c 100644 --- a/jdk/src/macosx/native/sun/awt/CMenu.m +++ b/jdk/src/macosx/native/sun/awt/CMenu.m @@ -52,7 +52,6 @@ AWT_ASSERT_APPKIT_THREAD; fMenu = nil; [super dealloc]; } -//- (void)finalize { [super finalize]; } - (void)addJavaSubmenu:(CMenu *)submenu { [ThreadUtilities performOnMainThread:@selector(addNativeItem_OnAppKitThread:) on:self withObject:submenu waitUntilDone:YES]; @@ -169,10 +168,6 @@ JNF_COCOA_ENTER(env); // Add it to the parent menu [((CMenu *)jlong_to_ptr(parentMenu)) addJavaSubmenu: aCMenu]; - if (aCMenu) { - CFRetain(aCMenu); // GC - [aCMenu release]; - } JNF_COCOA_EXIT(env); @@ -209,10 +204,6 @@ JNF_COCOA_ENTER(env); [parent javaSetHelpMenu: aCMenu]; } - if (aCMenu) { - CFRetain(aCMenu); // GC - [aCMenu release]; - } JNF_COCOA_EXIT(env); return ptr_to_jlong(aCMenu); } @@ -275,13 +266,9 @@ Java_sun_lwawt_macosx_CMenu_nativeGetNSMenu NSMenu* nsMenu = NULL; JNF_COCOA_ENTER(env); - nsMenu = [((CMenu *)jlong_to_ptr(menuObject)) menu]; -JNF_COCOA_EXIT(env); - // Strong retain this menu; it'll get released in Java_apple_laf_ScreenMenu_addMenuListeners - if (nsMenu) { - CFRetain(nsMenu); // GC - } + nsMenu = [[((CMenu *)jlong_to_ptr(menuObject)) menu] retain]; +JNF_COCOA_EXIT(env); return ptr_to_jlong(nsMenu); } diff --git a/jdk/src/macosx/native/sun/awt/CMenuBar.m b/jdk/src/macosx/native/sun/awt/CMenuBar.m index 3bf4f779fb5..34ba099331b 100644 --- a/jdk/src/macosx/native/sun/awt/CMenuBar.m +++ b/jdk/src/macosx/native/sun/awt/CMenuBar.m @@ -405,10 +405,6 @@ Java_sun_lwawt_macosx_CMenuBar_nativeCreateMenuBar JNF_COCOA_EXIT(env); - if (aCMenuBar) { - CFRetain(aCMenuBar); // GC - [aCMenuBar release]; - } return ptr_to_jlong(aCMenuBar); } diff --git a/jdk/src/macosx/native/sun/awt/CMenuComponent.m b/jdk/src/macosx/native/sun/awt/CMenuComponent.m index c8b3766ad23..c3bff14241c 100644 --- a/jdk/src/macosx/native/sun/awt/CMenuComponent.m +++ b/jdk/src/macosx/native/sun/awt/CMenuComponent.m @@ -51,8 +51,7 @@ fPeer = NULL; [self cleanup]; - - CFRelease(self); // GC + [self release]; } // The method is used by all subclasses, since the process of the creation @@ -64,9 +63,6 @@ [argValue addObject: aCMenuItem]; } -//-(void) dealloc { [super dealloc]; } -//- (void)finalize { [super finalize]; } - @end /* diff --git a/jdk/src/macosx/native/sun/awt/CMenuItem.m b/jdk/src/macosx/native/sun/awt/CMenuItem.m index 3a048f586d0..8e483468074 100644 --- a/jdk/src/macosx/native/sun/awt/CMenuItem.m +++ b/jdk/src/macosx/native/sun/awt/CMenuItem.m @@ -420,11 +420,6 @@ JNF_COCOA_ENTER(env); // setLabel will be called after creation completes. - if (aCMenuItem) { - CFRetain(aCMenuItem); // GC - [aCMenuItem release]; - } - JNF_COCOA_EXIT(env); return ptr_to_jlong(aCMenuItem); } diff --git a/jdk/src/macosx/native/sun/awt/CPopupMenu.m b/jdk/src/macosx/native/sun/awt/CPopupMenu.m index 287e97a2acf..11869a52403 100644 --- a/jdk/src/macosx/native/sun/awt/CPopupMenu.m +++ b/jdk/src/macosx/native/sun/awt/CPopupMenu.m @@ -66,8 +66,6 @@ JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ aCPopupMenu = [[CPopupMenu alloc] initWithPeer:cPeerObjGlobal]; - CFRetain(aCPopupMenu); - [aCPopupMenu release]; }]; JNF_COCOA_EXIT(env); diff --git a/jdk/src/macosx/native/sun/awt/CPrinterJob.m b/jdk/src/macosx/native/sun/awt/CPrinterJob.m index 219f65b49d9..4a85a916976 100644 --- a/jdk/src/macosx/native/sun/awt/CPrinterJob.m +++ b/jdk/src/macosx/native/sun/awt/CPrinterJob.m @@ -469,8 +469,6 @@ JNF_COCOA_ENTER(env); // safety is assured by the java side of this call. NSPrintInfo* printInfo = createDefaultNSPrintInfo(env, NULL); - if (printInfo) CFRetain(printInfo); // GC - [printInfo release]; result = ptr_to_jlong(printInfo); @@ -490,7 +488,7 @@ JNF_COCOA_ENTER(env); if (nsPrintInfo != -1) { NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr(nsPrintInfo); - if (printInfo) CFRelease(printInfo); // GC + [printInfo release]; } JNF_COCOA_EXIT(env); } diff --git a/jdk/src/macosx/native/sun/awt/CSystemColors.m b/jdk/src/macosx/native/sun/awt/CSystemColors.m index 0f3fab5b444..f83c66036e0 100644 --- a/jdk/src/macosx/native/sun/awt/CSystemColors.m +++ b/jdk/src/macosx/native/sun/awt/CSystemColors.m @@ -75,7 +75,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_systemColorsChanged, jc_LWCToolkit, "systemCol sColors = (NSColor**)malloc(sizeof(NSColor*) * java_awt_SystemColor_NUM_COLORS); } else { for (i = 0; i < java_awt_SystemColor_NUM_COLORS; i++) { - if (sColors[i] != NULL) CFRelease(sColors[i]); // GC + if (sColors[i] != NULL) [sColors[i] release]; } } @@ -108,14 +108,14 @@ static JNF_STATIC_MEMBER_CACHE(jm_systemColorsChanged, jc_LWCToolkit, "systemCol sColors[java_awt_SystemColor_INFO_TEXT] = [NSColor textColor]; for (i = 0; i < java_awt_SystemColor_NUM_COLORS; i++) { - if (sColors[i] != NULL) CFRetain(sColors[i]); // GC + [sColors[i] retain]; } if (appleColors == nil) { appleColors = (NSColor**)malloc(sizeof(NSColor*) * sun_lwawt_macosx_LWCToolkit_NUM_APPLE_COLORS); } else { for (i = 0; i < sun_lwawt_macosx_LWCToolkit_NUM_APPLE_COLORS; i++) { - if (appleColors[i] != NULL) CFRelease(appleColors[i]); // GC + if (appleColors[i] != NULL) [appleColors[i] release]; } } @@ -124,7 +124,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_systemColorsChanged, jc_LWCToolkit, "systemCol appleColors[sun_lwawt_macosx_LWCToolkit_INACTIVE_SELECTION_FOREGROUND_COLOR] = [NSColor controlDarkShadowColor]; for (i = 0; i < sun_lwawt_macosx_LWCToolkit_NUM_APPLE_COLORS; i++) { - if (appleColors[i] != NULL) CFRetain(appleColors[i]); // GC + [appleColors[i] retain]; } } diff --git a/jdk/src/macosx/native/sun/awt/ImageSurfaceData.m b/jdk/src/macosx/native/sun/awt/ImageSurfaceData.m index 2d3669f2d90..798ff2de7cd 100644 --- a/jdk/src/macosx/native/sun/awt/ImageSurfaceData.m +++ b/jdk/src/macosx/native/sun/awt/ImageSurfaceData.m @@ -1497,7 +1497,7 @@ PRINT("ImageSD_dispose") } if (isdo->nsRef) { - CFRelease(isdo->nsRef); // GC + [isdo->nsRef release]; isdo->nsRef = nil; } diff --git a/jdk/src/macosx/native/sun/awt/JavaAccessibilityAction.m b/jdk/src/macosx/native/sun/awt/JavaAccessibilityAction.m index 9afd1ff527e..d0f8b871004 100644 --- a/jdk/src/macosx/native/sun/awt/JavaAccessibilityAction.m +++ b/jdk/src/macosx/native/sun/awt/JavaAccessibilityAction.m @@ -55,20 +55,6 @@ [super dealloc]; } -- (void)finalize -{ - JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; - - JNFDeleteGlobalRef(env, fAccessibleAction); - fAccessibleAction = NULL; - - JNFDeleteGlobalRef(env, fComponent); - fComponent = NULL; - - [super finalize]; -} - - - (NSString *)getDescription { static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleActionDescription, sjc_CAccessibility, "getAccessibleActionDescription", "(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)Ljava/lang/String;"); @@ -116,19 +102,6 @@ [super dealloc]; } -- (void)finalize -{ - JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; - - JNFDeleteGlobalRef(env, fTabGroup); - fTabGroup = NULL; - - JNFDeleteGlobalRef(env, fComponent); - fComponent = NULL; - - [super finalize]; -} - - (NSString *)getDescription { return @"click"; diff --git a/jdk/src/macosx/native/sun/awt/JavaComponentAccessibility.m b/jdk/src/macosx/native/sun/awt/JavaComponentAccessibility.m index d20e70fe67b..e5260a2b6a6 100644 --- a/jdk/src/macosx/native/sun/awt/JavaComponentAccessibility.m +++ b/jdk/src/macosx/native/sun/awt/JavaComponentAccessibility.m @@ -192,20 +192,6 @@ static NSObject *sAttributeNamesLOCK = nil; [super dealloc]; } -- (void)finalize -{ - [self unregisterFromCocoaAXSystem]; - - JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; - - JNFDeleteGlobalRef(env, fAccessible); - fAccessible = NULL; - - JNFDeleteGlobalRef(env, fComponent); - fComponent = NULL; - - [super finalize]; -} - (void)postValueChanged { @@ -355,8 +341,8 @@ static NSObject *sAttributeNamesLOCK = nil; // must init freshly -alloc'd object [newChild initWithParent:parent withEnv:env withAccessible:jCAX withIndex:index withView:view withJavaRole:javaRole]; // must init new instance - // must hard CFRetain() pointer poked into Java object - CFRetain(newChild); + // must hard retain pointer poked into Java object + [newChild retain]; JNFSetLongField(env, jCAX, jf_ptr, ptr_to_jlong(newChild)); // return autoreleased instance @@ -1397,18 +1383,6 @@ static BOOL ObjectEquals(JNIEnv *env, jobject a, jobject b, jobject component); [super dealloc]; } -- (void)finalize -{ - JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; - - if (fTabGroupAxContext != NULL) { - JNFDeleteGlobalRef(env, fTabGroupAxContext); - fTabGroupAxContext = NULL; - } - - [super finalize]; -} - - (id)accessibilityValueAttribute { JNIEnv *env = [ThreadUtilities getJNIEnv]; diff --git a/jdk/src/macosx/native/sun/awt/LWCToolkit.m b/jdk/src/macosx/native/sun/awt/LWCToolkit.m index 5e2dd6cb43d..29d57b805fd 100644 --- a/jdk/src/macosx/native/sun/awt/LWCToolkit.m +++ b/jdk/src/macosx/native/sun/awt/LWCToolkit.m @@ -291,17 +291,15 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_LWCToolkit_createAWTRunLoopMediato { AWT_ASSERT_APPKIT_THREAD; - AWTRunLoopObject *o = nil; + jlong result; +JNF_COCOA_ENTER(env); // We double retain because this object is owned by both main thread and "other" thread // We release in both doAWTRunLoop and stopAWTRunLoop - o = [[AWTRunLoopObject alloc] init]; - if (o) { - CFRetain(o); // GC - CFRetain(o); // GC - [o release]; - } - return ptr_to_jlong(o); + result = ptr_to_jlong([[[AWTRunLoopObject alloc] init] retain]); +JNF_COCOA_EXIT(env); + + return result; } /* @@ -336,10 +334,7 @@ JNF_COCOA_ENTER(env); } } - - - CFRelease(mediatorObject); - + [mediatorObject release]; JNF_COCOA_EXIT(env); } @@ -357,7 +352,7 @@ JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThread:@selector(endRunLoop) on:mediatorObject withObject:nil waitUntilDone:NO]; - CFRelease(mediatorObject); + [mediatorObject release]; JNF_COCOA_EXIT(env); } diff --git a/jdk/src/macosx/native/sun/awt/PrintModel.m b/jdk/src/macosx/native/sun/awt/PrintModel.m index 8a172d7e96e..e2e44cca625 100644 --- a/jdk/src/macosx/native/sun/awt/PrintModel.m +++ b/jdk/src/macosx/native/sun/awt/PrintModel.m @@ -48,7 +48,6 @@ [super dealloc]; } -//- (void)finalize { [super finalize]; } - (BOOL)runPageSetup { __block BOOL fResult = NO; @@ -86,8 +85,8 @@ AWT_ASSERT_NOT_APPKIT_THREAD; fResult = [self safePrintLoop:printerView withEnv:env]; } else { // Retain these so they don't go away while we're in Java - CFRetain(self); // GC - if (printerView) CFRetain(printerView); // GC + [self retain]; + [printerView retain]; static JNF_CLASS_CACHE(jc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob"); static JNF_STATIC_MEMBER_CACHE(jm_detachPrintLoop, jc_CPrinterJob, "detachPrintLoop", "(JJ)V"); @@ -134,8 +133,8 @@ JNF_COCOA_ENTER(env); [model safePrintLoop:arg withEnv:env]; // These are to match the retains in runPrintLoopWithView: - if (model) CFRelease(model); // GC - if (arg) CFRelease(arg); // GC + [model release]; + [arg release]; JNF_COCOA_EXIT(env); } diff --git a/jdk/src/macosx/native/sun/osxapp/NSApplicationAWT.m b/jdk/src/macosx/native/sun/osxapp/NSApplicationAWT.m index b55f1b76c21..3e11e1dda7e 100644 --- a/jdk/src/macosx/native/sun/osxapp/NSApplicationAWT.m +++ b/jdk/src/macosx/native/sun/osxapp/NSApplicationAWT.m @@ -71,7 +71,6 @@ AWT_ASSERT_APPKIT_THREAD; [super dealloc]; } -//- (void)finalize { [super finalize]; } - (void)finishLaunching {