RFR: 8276700: Improve java.lang.ref.Cleaner javadocs
Hendrik Schreiber
hschreiber at openjdk.java.net
Mon Nov 8 13:30:55 UTC 2021
On Fri, 5 Nov 2021 22:22:12 GMT, Mandy Chung <mchung at openjdk.org> wrote:
>> Trivial improvement.
>>
>> Explicitly show how to create a `Cleaner` instance using `Cleaner.create()`.
>> Repeat (again) in the code example that the `State` `Runnable `should be implemented as static class and not reference the instance to be cleaned, to make the point even more clear to those people who never read the javadoc *prose*.
>>
>> I have signed the OCA a while back as [hschreiber](https://openjdk.java.net/census#hschreiber).
>
> src/java.base/share/classes/java/lang/ref/Cleaner.java line 93:
>
>> 91: *
>> 92: * // Static state class, capturing information necessary for
>> 93: * // cleanup, but no reference to the instance being cleaned
>
> Suggestion:
>
> * // State class captures information necessary for cleanup.
> * // It must hold no reference to the instance being cleaned
> * // and therefore it is a static inner class in this CleaningExample.
>
>
> Would this be clearer?
I don't believe so. `no reference to the instance being cleaned` is the essential part (to me).
-------------
PR: https://git.openjdk.java.net/jdk/pull/6076
More information about the core-libs-dev
mailing list