提交 870b63fd 编写于 作者: M mcherkas

8037099: [macosx] Remove all references to GC from native OBJ-C code

Reviewed-by: serb
上级 a435de1f
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -103,8 +103,6 @@ JNF_COCOA_ENTER(env); ...@@ -103,8 +103,6 @@ JNF_COCOA_ENTER(env);
CALayer *windowLayer = jlong_to_ptr(windowLayerPtr); CALayer *windowLayer = jlong_to_ptr(windowLayerPtr);
surfaceLayers = [[AWTSurfaceLayers alloc] initWithWindowLayer: windowLayer]; surfaceLayers = [[AWTSurfaceLayers alloc] initWithWindowLayer: windowLayer];
CFRetain(surfaceLayers);
[surfaceLayers release];
}]; }];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
......
...@@ -114,9 +114,9 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -114,9 +114,9 @@ AWT_ASSERT_APPKIT_THREAD;
remoteLayer.parentLayer = parentLayer; remoteLayer.parentLayer = parentLayer;
remoteLayer.remoteLayer = NULL; remoteLayer.remoteLayer = NULL;
remoteLayer.jrsRemoteLayer = [remoteLayer createRemoteLayerBoundTo:JRSRemotePort]; remoteLayer.jrsRemoteLayer = [remoteLayer createRemoteLayerBoundTo:JRSRemotePort];
CFRetain(remoteLayer); // REMIND [remoteLayer retain]; // REMIND
remoteLayer.frame = CGRectMake(0, 0, 720, 500); // REMIND remoteLayer.frame = CGRectMake(0, 0, 720, 500); // REMIND
CFRetain(remoteLayer.jrsRemoteLayer); // REMIND [remoteLayer.jrsRemoteLayer retain]; // REMIND
int layerID = [remoteLayer.jrsRemoteLayer layerID]; int layerID = [remoteLayer.jrsRemoteLayer layerID];
NSLog(@"layer id to send = %d", layerID); NSLog(@"layer id to send = %d", layerID);
sendLayerID(layerID); sendLayerID(layerID);
...@@ -1340,12 +1340,9 @@ JNF_COCOA_ENTER(env); ...@@ -1340,12 +1340,9 @@ JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
CALayer *windowLayer = jlong_to_ptr(windowLayerPtr); CALayer *windowLayer = jlong_to_ptr(windowLayerPtr);
AWTView *view = [[AWTView alloc] initWithRect:rect newView = [[AWTView alloc] initWithRect:rect
platformView:cPlatformView platformView:cPlatformView
windowLayer:windowLayer]; windowLayer:windowLayer];
CFRetain(view);
[view release]; // GC
newView = view;
}]; }];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
......
/* /*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -916,7 +916,7 @@ JNF_COCOA_ENTER(env); ...@@ -916,7 +916,7 @@ JNF_COCOA_ENTER(env);
contentView:contentView]; contentView:contentView];
// the window is released is CPlatformWindow.nativeDispose() // the window is released is CPlatformWindow.nativeDispose()
if (window) CFRetain(window.nsWindow); if (window) [window.nsWindow retain];
}]; }];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -255,8 +255,6 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -255,8 +255,6 @@ AWT_ASSERT_APPKIT_THREAD;
[super dealloc]; [super dealloc];
} }
//- (void)finalize { [super finalize]; } // GC
#pragma mark Callbacks from AppKit #pragma mark Callbacks from AppKit
...@@ -623,8 +621,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeGetDockIc ...@@ -623,8 +621,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeGetDockIc
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
image = [ApplicationDelegate _dockIconImage]; image = [[ApplicationDelegate _dockIconImage] retain];
CFRetain(image);
}]; }];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
......
/* /*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -72,7 +72,6 @@ static CClipboard *sClipboard = nil; ...@@ -72,7 +72,6 @@ static CClipboard *sClipboard = nil;
[super dealloc]; [super dealloc];
} }
//- (void)finalize { [super finalize]; }
- (NSData *)data { - (NSData *)data {
return fData; return fData;
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -79,7 +79,7 @@ JNF_COCOA_ENTER(env); ...@@ -79,7 +79,7 @@ JNF_COCOA_ENTER(env);
LSApplicationParameters params = {0, flags, NULL, NULL, NULL, NULL, NULL}; LSApplicationParameters params = {0, flags, NULL, NULL, NULL, NULL, NULL};
status = LSOpenURLsWithRole((CFArrayRef)[NSArray arrayWithObject:url], kLSRolesAll, NULL, &params, NULL, 0); status = LSOpenURLsWithRole((CFArrayRef)[NSArray arrayWithObject:url], kLSRolesAll, NULL, &params, NULL, 0);
CFRelease(url); [url release];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
return status; return status;
......
/* /*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -193,7 +193,7 @@ static BOOL sNeedsEnter; ...@@ -193,7 +193,7 @@ static BOOL sNeedsEnter;
fFormatMap = NULL; fFormatMap = NULL;
} }
CFRelease(self); // GC [self release];
} }
- (void)dealloc - (void)dealloc
...@@ -209,8 +209,6 @@ static BOOL sNeedsEnter; ...@@ -209,8 +209,6 @@ static BOOL sNeedsEnter;
[super dealloc]; [super dealloc];
} }
//- (void)finalize { [super finalize]; }
// Appropriated from Windows' awt_DataTransferer.cpp: // Appropriated from Windows' awt_DataTransferer.cpp:
// //
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -67,10 +67,6 @@ JNF_COCOA_ENTER(env); ...@@ -67,10 +67,6 @@ JNF_COCOA_ENTER(env);
}]; }];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
if (dragSource) {
CFRetain(dragSource); // GC
[dragSource release];
}
return ptr_to_jlong(dragSource); return ptr_to_jlong(dragSource);
} }
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -171,7 +171,7 @@ extern JNFClassInfo jc_CDropTargetContextPeer; ...@@ -171,7 +171,7 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
fDropTargetContextPeer = NULL; fDropTargetContextPeer = NULL;
} }
CFRelease(self); [self release];
} }
- (void)dealloc - (void)dealloc
...@@ -187,7 +187,6 @@ extern JNFClassInfo jc_CDropTargetContextPeer; ...@@ -187,7 +187,6 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
[super dealloc]; [super dealloc];
} }
//- (void)finalize { [super finalize]; }
- (NSInteger) getDraggingSequenceNumber - (NSInteger) getDraggingSequenceNumber
{ {
...@@ -724,10 +723,6 @@ JNF_COCOA_ENTER(env); ...@@ -724,10 +723,6 @@ JNF_COCOA_ENTER(env);
dropTarget = [[CDropTarget alloc] init:jdroptarget component:jcomponent peer:jpeer control:controlObj]; dropTarget = [[CDropTarget alloc] init:jdroptarget component:jcomponent peer:jpeer control:controlObj];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
if (dropTarget) {
CFRetain(dropTarget); // GC
[dropTarget release];
}
return ptr_to_jlong(dropTarget); return ptr_to_jlong(dropTarget);
} }
......
/* /*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -88,7 +88,6 @@ canChooseDirectories:(BOOL)inChooseDirectories ...@@ -88,7 +88,6 @@ canChooseDirectories:(BOOL)inChooseDirectories
[super dealloc]; [super dealloc];
} }
//- (void)finalize { [super finalize]; }
- (void)safeSaveOrLoad { - (void)safeSaveOrLoad {
NSSavePanel *thePanel = nil; NSSavePanel *thePanel = nil;
...@@ -168,9 +167,9 @@ canChooseDirectories:(BOOL)inChooseDirectories ...@@ -168,9 +167,9 @@ canChooseDirectories:(BOOL)inChooseDirectories
} }
// ask the file filter up in Java // ask the file filter up in Java
CFStringRef filePath = CFURLCopyFileSystemPath((CFURLRef)url, kCFURLPOSIXPathStyle); NSString* filePath = (NSString*)CFURLCopyFileSystemPath((CFURLRef)url, kCFURLPOSIXPathStyle);
BOOL shouldEnableFile = [self askFilenameFilter:(NSString *)filePath]; BOOL shouldEnableFile = [self askFilenameFilter:filePath];
CFRelease(filePath); [filePath release];
return shouldEnableFile; return shouldEnableFile;
} }
......
/* /*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -163,8 +163,7 @@ Java_sun_awt_CGraphicsEnvironment_registerDisplayReconfiguration ...@@ -163,8 +163,7 @@ Java_sun_awt_CGraphicsEnvironment_registerDisplayReconfiguration
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
JNFWeakJObjectWrapper *wrapper = [JNFWeakJObjectWrapper wrapperWithJObject:this withEnv:env]; JNFWeakJObjectWrapper *wrapper = [[JNFWeakJObjectWrapper wrapperWithJObject:this withEnv:env] retain];
CFRetain(wrapper); // pin from ObjC-GC
/* Register the callback */ /* Register the callback */
if (CGDisplayRegisterReconfigurationCallback(&displaycb_handle, wrapper) != kCGErrorSuccess) { if (CGDisplayRegisterReconfigurationCallback(&displaycb_handle, wrapper) != kCGErrorSuccess) {
...@@ -204,8 +203,7 @@ JNF_COCOA_ENTER(env); ...@@ -204,8 +203,7 @@ JNF_COCOA_ENTER(env);
} }
[wrapper setJObject:NULL withEnv:env]; // more efficiant to pre-clear [wrapper setJObject:NULL withEnv:env]; // more efficiant to pre-clear
[wrapper release];
CFRelease(wrapper);
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
/* /*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -115,14 +115,9 @@ JNF_COCOA_ENTER(env); ...@@ -115,14 +115,9 @@ JNF_COCOA_ENTER(env);
NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height); NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
if (imageRep) { if (imageRep) {
NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)]; NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(width, height)] retain];
[nsImage addRepresentation:imageRep]; [nsImage addRepresentation:imageRep];
[imageRep release]; [imageRep release];
if (nsImage != nil) {
CFRetain(nsImage); // GC
}
result = ptr_to_jlong(nsImage); result = ptr_to_jlong(nsImage);
} }
...@@ -165,13 +160,8 @@ JNF_COCOA_ENTER(env); ...@@ -165,13 +160,8 @@ JNF_COCOA_ENTER(env);
(*env)->ReleaseIntArrayElements(env, widths, ws, JNI_ABORT); (*env)->ReleaseIntArrayElements(env, widths, ws, JNI_ABORT);
} }
if ([reps count]) { if ([reps count]) {
NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0, 0)]; NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(0, 0)] retain];
[nsImage addRepresentations: reps]; [nsImage addRepresentations: reps];
if (nsImage != nil) {
CFRetain(nsImage); // GC
}
result = ptr_to_jlong(nsImage); result = ptr_to_jlong(nsImage);
} }
...@@ -194,8 +184,7 @@ JNF_COCOA_ENTER(env); ...@@ -194,8 +184,7 @@ JNF_COCOA_ENTER(env);
IconRef iconRef; IconRef iconRef;
if (noErr == GetIconRef(kOnSystemDisk, kSystemIconsCreator, selector, &iconRef)) { if (noErr == GetIconRef(kOnSystemDisk, kSystemIconsCreator, selector, &iconRef)) {
image = [[NSImage alloc] initWithIconRef:iconRef]; image = [[[NSImage alloc] initWithIconRef:iconRef] retain];
if (image) CFRetain(image); // GC
ReleaseIconRef(iconRef); ReleaseIconRef(iconRef);
} }
...@@ -217,8 +206,7 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromFile ...@@ -217,8 +206,7 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromFile
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
NSString *path = JNFNormalizedNSStringForPath(env, file); NSString *path = JNFNormalizedNSStringForPath(env, file);
image = [[NSImage alloc] initByReferencingFile:path]; image = [[[NSImage alloc] initByReferencingFile:path] retain];
if (image) CFRetain(image); // GC
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
...@@ -239,9 +227,8 @@ JNF_COCOA_ENTER(env); ...@@ -239,9 +227,8 @@ JNF_COCOA_ENTER(env);
NSString *path = JNFNormalizedNSStringForPath(env, file); NSString *path = JNFNormalizedNSStringForPath(env, file);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
image = [[NSWorkspace sharedWorkspace] iconForFile:path]; image = [[[NSWorkspace sharedWorkspace] iconForFile:path] retain];
[image setScalesWhenResized:TRUE]; [image setScalesWhenResized:TRUE];
if (image) CFRetain(image); // GC
}]; }];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
...@@ -261,8 +248,7 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromImag ...@@ -261,8 +248,7 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromImag
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
image = [NSImage imageNamed:JNFJavaToNSString(env, name)]; image = [[NSImage imageNamed:JNFJavaToNSString(env, name)] retain];
if (image) CFRetain(image); // GC
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
......
...@@ -52,7 +52,6 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -52,7 +52,6 @@ AWT_ASSERT_APPKIT_THREAD;
fMenu = nil; fMenu = nil;
[super dealloc]; [super dealloc];
} }
//- (void)finalize { [super finalize]; }
- (void)addJavaSubmenu:(CMenu *)submenu { - (void)addJavaSubmenu:(CMenu *)submenu {
[ThreadUtilities performOnMainThread:@selector(addNativeItem_OnAppKitThread:) on:self withObject:submenu waitUntilDone:YES]; [ThreadUtilities performOnMainThread:@selector(addNativeItem_OnAppKitThread:) on:self withObject:submenu waitUntilDone:YES];
...@@ -168,10 +167,6 @@ JNF_COCOA_ENTER(env); ...@@ -168,10 +167,6 @@ JNF_COCOA_ENTER(env);
// Add it to the parent menu // Add it to the parent menu
[((CMenu *)jlong_to_ptr(parentMenu)) addJavaSubmenu: aCMenu]; [((CMenu *)jlong_to_ptr(parentMenu)) addJavaSubmenu: aCMenu];
if (aCMenu) {
CFRetain(aCMenu); // GC
[aCMenu release];
}
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
...@@ -208,10 +203,6 @@ JNF_COCOA_ENTER(env); ...@@ -208,10 +203,6 @@ JNF_COCOA_ENTER(env);
[parent javaSetHelpMenu: aCMenu]; [parent javaSetHelpMenu: aCMenu];
} }
if (aCMenu) {
CFRetain(aCMenu); // GC
[aCMenu release];
}
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
return ptr_to_jlong(aCMenu); return ptr_to_jlong(aCMenu);
} }
...@@ -274,13 +265,9 @@ Java_sun_lwawt_macosx_CMenu_nativeGetNSMenu ...@@ -274,13 +265,9 @@ Java_sun_lwawt_macosx_CMenu_nativeGetNSMenu
NSMenu* nsMenu = NULL; NSMenu* nsMenu = NULL;
JNF_COCOA_ENTER(env); 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 // Strong retain this menu; it'll get released in Java_apple_laf_ScreenMenu_addMenuListeners
if (nsMenu) { nsMenu = [[((CMenu *)jlong_to_ptr(menuObject)) menu] retain];
CFRetain(nsMenu); // GC JNF_COCOA_EXIT(env);
}
return ptr_to_jlong(nsMenu); return ptr_to_jlong(nsMenu);
} }
...@@ -398,10 +398,6 @@ Java_sun_lwawt_macosx_CMenuBar_nativeCreateMenuBar ...@@ -398,10 +398,6 @@ Java_sun_lwawt_macosx_CMenuBar_nativeCreateMenuBar
} }
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
if (aCMenuBar) {
CFRetain(aCMenuBar); // GC
[aCMenuBar release];
}
return ptr_to_jlong(aCMenuBar); return ptr_to_jlong(aCMenuBar);
} }
......
...@@ -51,8 +51,7 @@ ...@@ -51,8 +51,7 @@
fPeer = NULL; fPeer = NULL;
[self cleanup]; [self cleanup];
[self release];
CFRelease(self); // GC
} }
// The method is used by all subclasses, since the process of the creation // The method is used by all subclasses, since the process of the creation
...@@ -64,9 +63,6 @@ ...@@ -64,9 +63,6 @@
[argValue addObject: aCMenuItem]; [argValue addObject: aCMenuItem];
} }
//-(void) dealloc { [super dealloc]; }
//- (void)finalize { [super finalize]; }
@end @end
/* /*
......
...@@ -403,11 +403,6 @@ JNF_COCOA_ENTER(env); ...@@ -403,11 +403,6 @@ JNF_COCOA_ENTER(env);
// setLabel will be called after creation completes. // setLabel will be called after creation completes.
if (aCMenuItem) {
CFRetain(aCMenuItem); // GC
[aCMenuItem release];
}
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
return ptr_to_jlong(aCMenuItem); return ptr_to_jlong(aCMenuItem);
} }
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -66,8 +66,6 @@ JNF_COCOA_ENTER(env); ...@@ -66,8 +66,6 @@ JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
aCPopupMenu = [[CPopupMenu alloc] initWithPeer:cPeerObjGlobal]; aCPopupMenu = [[CPopupMenu alloc] initWithPeer:cPeerObjGlobal];
CFRetain(aCPopupMenu);
[aCPopupMenu release];
}]; }];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -469,8 +469,6 @@ JNF_COCOA_ENTER(env); ...@@ -469,8 +469,6 @@ JNF_COCOA_ENTER(env);
// safety is assured by the java side of this call. // safety is assured by the java side of this call.
NSPrintInfo* printInfo = createDefaultNSPrintInfo(env, NULL); NSPrintInfo* printInfo = createDefaultNSPrintInfo(env, NULL);
if (printInfo) CFRetain(printInfo); // GC
[printInfo release];
result = ptr_to_jlong(printInfo); result = ptr_to_jlong(printInfo);
...@@ -490,7 +488,7 @@ JNF_COCOA_ENTER(env); ...@@ -490,7 +488,7 @@ JNF_COCOA_ENTER(env);
if (nsPrintInfo != -1) if (nsPrintInfo != -1)
{ {
NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr(nsPrintInfo); NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr(nsPrintInfo);
if (printInfo) CFRelease(printInfo); // GC [printInfo release];
} }
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
......
/* /*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -75,7 +75,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_systemColorsChanged, jc_LWCToolkit, "systemCol ...@@ -75,7 +75,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_systemColorsChanged, jc_LWCToolkit, "systemCol
sColors = (NSColor**)malloc(sizeof(NSColor*) * java_awt_SystemColor_NUM_COLORS); sColors = (NSColor**)malloc(sizeof(NSColor*) * java_awt_SystemColor_NUM_COLORS);
} else { } else {
for (i = 0; i < java_awt_SystemColor_NUM_COLORS; i++) { 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 ...@@ -108,14 +108,14 @@ static JNF_STATIC_MEMBER_CACHE(jm_systemColorsChanged, jc_LWCToolkit, "systemCol
sColors[java_awt_SystemColor_INFO_TEXT] = [NSColor textColor]; sColors[java_awt_SystemColor_INFO_TEXT] = [NSColor textColor];
for (i = 0; i < java_awt_SystemColor_NUM_COLORS; i++) { for (i = 0; i < java_awt_SystemColor_NUM_COLORS; i++) {
if (sColors[i] != NULL) CFRetain(sColors[i]); // GC [sColors[i] retain];
} }
if (appleColors == nil) { if (appleColors == nil) {
appleColors = (NSColor**)malloc(sizeof(NSColor*) * sun_lwawt_macosx_LWCToolkit_NUM_APPLE_COLORS); appleColors = (NSColor**)malloc(sizeof(NSColor*) * sun_lwawt_macosx_LWCToolkit_NUM_APPLE_COLORS);
} else { } else {
for (i = 0; i < sun_lwawt_macosx_LWCToolkit_NUM_APPLE_COLORS; i++) { 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 ...@@ -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]; appleColors[sun_lwawt_macosx_LWCToolkit_INACTIVE_SELECTION_FOREGROUND_COLOR] = [NSColor controlDarkShadowColor];
for (i = 0; i < sun_lwawt_macosx_LWCToolkit_NUM_APPLE_COLORS; i++) { for (i = 0; i < sun_lwawt_macosx_LWCToolkit_NUM_APPLE_COLORS; i++) {
if (appleColors[i] != NULL) CFRetain(appleColors[i]); // GC [appleColors[i] retain];
} }
} }
......
/* /*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1497,7 +1497,7 @@ PRINT("ImageSD_dispose") ...@@ -1497,7 +1497,7 @@ PRINT("ImageSD_dispose")
} }
if (isdo->nsRef) { if (isdo->nsRef) {
CFRelease(isdo->nsRef); // GC [isdo->nsRef release];
isdo->nsRef = nil; isdo->nsRef = nil;
} }
......
...@@ -55,19 +55,6 @@ ...@@ -55,19 +55,6 @@
[super dealloc]; [super dealloc];
} }
- (void)finalize
{
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
JNFDeleteWeakGlobalRef(env, fAccessibleAction);
fAccessibleAction = NULL;
JNFDeleteWeakGlobalRef(env, fComponent);
fComponent = NULL;
[super finalize];
}
- (NSString *)getDescription - (NSString *)getDescription
{ {
...@@ -127,19 +114,6 @@ ...@@ -127,19 +114,6 @@
[super dealloc]; [super dealloc];
} }
- (void)finalize
{
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
JNFDeleteWeakGlobalRef(env, fTabGroup);
fTabGroup = NULL;
JNFDeleteWeakGlobalRef(env, fComponent);
fComponent = NULL;
[super finalize];
}
- (NSString *)getDescription - (NSString *)getDescription
{ {
return @"click"; return @"click";
......
...@@ -194,20 +194,6 @@ static NSObject *sAttributeNamesLOCK = nil; ...@@ -194,20 +194,6 @@ static NSObject *sAttributeNamesLOCK = nil;
[super dealloc]; [super dealloc];
} }
- (void)finalize
{
[self unregisterFromCocoaAXSystem];
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
(*env)->DeleteWeakGlobalRef(env, fAccessible);
fAccessible = NULL;
(*env)->DeleteWeakGlobalRef(env, fComponent);
fComponent = NULL;
[super finalize];
}
- (void)postValueChanged - (void)postValueChanged
{ {
...@@ -371,8 +357,8 @@ static NSObject *sAttributeNamesLOCK = nil; ...@@ -371,8 +357,8 @@ static NSObject *sAttributeNamesLOCK = nil;
// must init freshly -alloc'd object // must init freshly -alloc'd object
[newChild initWithParent:parent withEnv:env withAccessible:jCAX withIndex:index withView:view withJavaRole:javaRole]; // must init new instance [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 // must hard retain pointer poked into Java object
CFRetain(newChild); [newChild retain];
JNFSetLongField(env, jCAX, jf_ptr, ptr_to_jlong(newChild)); JNFSetLongField(env, jCAX, jf_ptr, ptr_to_jlong(newChild));
(*env)->DeleteLocalRef(env, jCAX); (*env)->DeleteLocalRef(env, jCAX);
...@@ -1498,18 +1484,6 @@ static BOOL ObjectEquals(JNIEnv *env, jobject a, jobject b, jobject component); ...@@ -1498,18 +1484,6 @@ static BOOL ObjectEquals(JNIEnv *env, jobject a, jobject b, jobject component);
[super dealloc]; [super dealloc];
} }
- (void)finalize
{
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
if (fTabGroupAxContext != NULL) {
JNFDeleteWeakGlobalRef(env, fTabGroupAxContext);
fTabGroupAxContext = NULL;
}
[super finalize];
}
- (id)accessibilityValueAttribute - (id)accessibilityValueAttribute
{ {
JNIEnv *env = [ThreadUtilities getJNIEnv]; JNIEnv *env = [ThreadUtilities getJNIEnv];
......
/* /*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -249,17 +249,15 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_LWCToolkit_createAWTRunLoopMediato ...@@ -249,17 +249,15 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_LWCToolkit_createAWTRunLoopMediato
{ {
AWT_ASSERT_APPKIT_THREAD; 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 double retain because this object is owned by both main thread and "other" thread
// We release in both doAWTRunLoop and stopAWTRunLoop // We release in both doAWTRunLoop and stopAWTRunLoop
o = [[AWTRunLoopObject alloc] init]; result = ptr_to_jlong([[[AWTRunLoopObject alloc] init] retain]);
if (o) { JNF_COCOA_EXIT(env);
CFRetain(o); // GC
CFRetain(o); // GC return result;
[o release];
}
return ptr_to_jlong(o);
} }
/* /*
...@@ -296,10 +294,7 @@ JNF_COCOA_ENTER(env); ...@@ -296,10 +294,7 @@ JNF_COCOA_ENTER(env);
} }
} }
[mediatorObject release];
CFRelease(mediatorObject);
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
...@@ -317,7 +312,7 @@ JNF_COCOA_ENTER(env); ...@@ -317,7 +312,7 @@ JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThread:@selector(endRunLoop) on:mediatorObject withObject:nil waitUntilDone:NO]; [ThreadUtilities performOnMainThread:@selector(endRunLoop) on:mediatorObject withObject:nil waitUntilDone:NO];
CFRelease(mediatorObject); [mediatorObject release];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
......
/* /*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
[super dealloc]; [super dealloc];
} }
//- (void)finalize { [super finalize]; }
- (BOOL)runPageSetup { - (BOOL)runPageSetup {
__block BOOL fResult = NO; __block BOOL fResult = NO;
...@@ -86,8 +85,8 @@ AWT_ASSERT_NOT_APPKIT_THREAD; ...@@ -86,8 +85,8 @@ AWT_ASSERT_NOT_APPKIT_THREAD;
fResult = [self safePrintLoop:printerView withEnv:env]; fResult = [self safePrintLoop:printerView withEnv:env];
} else { } else {
// Retain these so they don't go away while we're in Java // Retain these so they don't go away while we're in Java
CFRetain(self); // GC [self retain];
if (printerView) CFRetain(printerView); // GC [printerView retain];
static JNF_CLASS_CACHE(jc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob"); static JNF_CLASS_CACHE(jc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob");
static JNF_STATIC_MEMBER_CACHE(jm_detachPrintLoop, jc_CPrinterJob, "detachPrintLoop", "(JJ)V"); static JNF_STATIC_MEMBER_CACHE(jm_detachPrintLoop, jc_CPrinterJob, "detachPrintLoop", "(JJ)V");
...@@ -134,8 +133,8 @@ JNF_COCOA_ENTER(env); ...@@ -134,8 +133,8 @@ JNF_COCOA_ENTER(env);
[model safePrintLoop:arg withEnv:env]; [model safePrintLoop:arg withEnv:env];
// These are to match the retains in runPrintLoopWithView: // These are to match the retains in runPrintLoopWithView:
if (model) CFRelease(model); // GC [model release];
if (arg) CFRelease(arg); // GC [arg release];
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -71,7 +71,6 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -71,7 +71,6 @@ AWT_ASSERT_APPKIT_THREAD;
[super dealloc]; [super dealloc];
} }
//- (void)finalize { [super finalize]; }
- (void)finishLaunching - (void)finishLaunching
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册