RFR: 8362289: [macOS] Remove finalize method in JRSUIControls.java [v4]
Phil Race
prr at openjdk.org
Tue Jul 22 20:00:03 UTC 2025
On Fri, 18 Jul 2025 03:34:49 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
>> Phil Race has updated the pull request incrementally with one additional commit since the last revision:
>>
>> JRSUIControl.java
>
>>Synchronized methods might be OK without, but the following methods are not synchronized, and access cfDictionaryPtr:
>
> Unfortunately this is actually true, in awt we even have a special class [CFRetainedResource](https://github.com/openjdk/jdk/blob/04c0b130f09c093797895cc928fe020d7e584cb9/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java#L36) which maintains a locks around the native pointer and prevents its usage after de-allocation(intentional or via finalize). It was implemented as part of JDK-8164143.
>
> I can migrate the current API of DIsposer to the something similar to CFRetainedResource as a follow up bug. The current one did not introduce the new issues, since implementation via finalize has the same bug.
> > I would recommend adding a `reachabiltyFence()` to `Disposer.addRecord()`, as @mrserb [suggests](https://github.com/openjdk/jdk/pull/26331/files#r2208586134).
...
> I will evaluate if we need to file a bug to use reachabiltyFence in the Disposer creation since that is a one-time contained thing but I have no reason to suppose it is needed in this class.
I have at least filed the [enhancement] bug on this : https://bugs.openjdk.org/browse/JDK-8363886
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26331#issuecomment-3104650964
More information about the client-libs-dev
mailing list