RFR: 8344332: (bf) Migrate DirectByteBuffer away from jdk.internal.ref.Cleaner [v2]

Brent Christian bchristi at openjdk.org
Fri Jun 27 21:24:57 UTC 2025


On Mon, 19 May 2025 20:34:35 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> src/java.base/share/classes/sun/nio/Cleaner.java line 31:
>> 
>>> 29:  * {@code Cleaner} represents an object and a cleaning action.
>>> 30:  */
>>> 31: public interface Cleaner {
>> 
>> Can this be renamed NIOCleaner or NIOBufClenaer or something to avoid the ambiguity between the other cleaner.
>
> I intentionally (re)used the "Cleaner" name to avoid a bunch of renames that
> would increase the size of the change and distract from the meat of it. I
> think the name to use might be affected by how the implementation of the set
> of cleanup objects might get merged between the new java.nio.BufferCleaner and
> java.lang.ref.Cleaner. Perhaps the java.lang.ref.Cleaner.Cleanable interface
> should be used throughout? I didn't want to expand this change to include
> those kinds of questions.

I would be in favor of renaming to avoid ambiguity. There is already `java.lang.ref.Cleaner` and `jdk.internal.ref.Cleaner`, and now this `Cleaner` is really the same thing as `java.lang.ref.Cleaner.Cleanable`.
It could be done as a follow-on change, if need-be.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25289#discussion_r2172727041


More information about the nio-dev mailing list