On Tue, 7 Jan 2025 19:38:23 GMT, Brent Christian <bchri...@openjdk.org> wrote:
>> This PR proposes to eliminate the capturing of `this` in the cleanup action >> of `AbstractMemorySegment::reinterpretInternal`. > > As a matter of style, I believe there is something to be said for writing out > cleaning actions as static nested classes, as one can/must include explicit > fields for all object and values that the `Runnable` object must reference. > But it's more verbose, of course. > > Also, some conversions of finalizer to Cleaner have included tests to ensure > that objects become unreachable as expected. (A relatively simple technique > is to add the objects in question into a WeakHashMap, and ensure they are > removed as expected.) > [GssContextCleanup.java](https://github.com/openjdk/jdk/blob/master/test/jdk/sun/security/jgss/GssContextCleanup.java) > and > [GssNameCleanup.java](https://github.com/openjdk/jdk/blob/master/test/jdk/sun/security/jgss/GssNameCleanup.java) > from [JDK-8284490](https://bugs.openjdk.org/browse/JDK-8284490) are > examples. I don't know if it's practical to construct such a test in this > case. > > Anyway, just a couple things to think about. Thanks for the tips @bchristi-git : https://bugs.openjdk.org/browse/JDK-8347249 ------------- PR Comment: https://git.openjdk.org/jdk/pull/22943#issuecomment-2577114779