RFR: 8362289: [macOS] Remove finalize method in JRSUIControls.java [v4]
Sergey Bylokhov
serb at openjdk.org
Tue Aug 12 19:45:20 UTC 2025
On Tue, 22 Jul 2025 05:03:23 GMT, Phil Race <prr at openjdk.org> wrote:
>What does that mean ?
>CFRetainedResource is extended by a lot of classes and it is hard to figure out how correctly it is used.
>I would take a big step back and look before extending what it does.
That code in CFRetainedResource handle the case when the native resource was cleared by the finalizer or directly via dispose method, and after that it is impossible to use the broken native ptr. And at the same time while the native pointer is in use it is impossible to dispose the native resource.
For example the similar issue exists in getHitForPoint. It reads cfDictionaryPtr and then passes it to native code. But it is possible that the object becomes unreachable at some point(during getHitForPoint execution), resulting in a broken pointer being passed to native code, which could lead to a crash. To prevent this, we can either add a reachabilityFence at the end of getHitForPoint, or use an approach similar to CFRetainedResource, ensuring that all usage of the native pointer is properly guarded.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26331#issuecomment-3180770974
More information about the client-libs-dev
mailing list