On Wed, 24 May 2023 12:46:45 GMT, Kevin Rushforth <k...@openjdk.org> wrote:
>> Lukasz Kostyra has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Release resources to prevent leaks > > modules/javafx.graphics/src/main/native-glass/mac/GlassViewDelegate.m line > 976: > >> 974: { >> 975: // create an image with contents of URL >> 976: NSString *fileURL = [[[NSString alloc] autorelease] >> initWithData:[pbItem dataForType:NSPasteboardTypeFileURL] >> encoding:NSUTF8StringEncoding]; > > Minor: The generally accepted pattern is to call `autorelease` after the > `init`, so as to not split `alloc` and `init`, so: > > > NSString *fileURL = [[[NSString alloc] initWithData:[pbItem > dataForType:NSPasteboardTypeFileURL] > encoding:NSUTF8StringEncoding] autorelease]; A functional reason why calling `autorelease` should be called after the `init` is that some objects, like `NSString`, might return a different object from the init method. Apple's docs for `NSArray initWithData:encoding:` says: Return Value: ... The returned object may be different from the original receiver. So this is no longer a minor suggestion, but a required change. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1089#discussion_r1204109920