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

Kim Barrett kbarrett at openjdk.org
Sun Jun 29 20:43:58 UTC 2025


On Fri, 27 Jun 2025 17:43:34 GMT, Brent Christian <bchristi at openjdk.org> wrote:

>> Kim Barrett has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 11 additional commits since the last revision:
>> 
>>  - Merge branch 'master' into direct-buffer-cleaner
>>  - Merge branch 'master' into direct-buffer-cleaner
>>  - Merge branch 'master' into direct-buffer-cleaner
>>  - Merge branch 'master' into direct-buffer-cleaner
>>  - add description of BufferCleaner class
>>  - exception handling in cleaner for backward consistency
>>  - detabify
>>  - move jdk.internal.nio.Cleaner to sun.nio
>>  - copyrights
>>  - remove java.nio use of jdk.internal.ref.Cleaner
>>  - ... and 1 more: https://git.openjdk.org/jdk/compare/ad875ca6...c995d97e
>
> src/java.base/share/classes/java/nio/Bits.java line 108:
> 
>> 106: 
>> 107:     private static final Object RESERVE_SLOWPATH_LOCK = new Object();
>> 108:     private static int RESERVE_GC_EPOCH = 0; // Never negative.
> 
> Can you add a comment on how this is used? Also, it seems more like a "counter".

I made some comment updates that I hope address this.

> src/java.base/share/classes/java/nio/Bits.java line 131:
> 
>> 129:             // Keep trying to reserve until either succeed or there is no
>> 130:             // further cleaning available from prior GCs. If the latter then
>> 131:             // GC to hopefully find more cleaning to do.
> 
> I think this comment could better describe what happens. For instance, only one thread at a time will GC, and each thread only GCs once (assuming I'm reading the code right).

I made some comment updates that I hope address this.

> src/java.base/share/classes/java/nio/BufferCleaner.java line 69:
> 
>> 67:         }
>> 68: 
>> 69:         public void clean() {
> 
> Could be `@Override`

Sure. Done.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25289#discussion_r2173909278
PR Review Comment: https://git.openjdk.org/jdk/pull/25289#discussion_r2173909513
PR Review Comment: https://git.openjdk.org/jdk/pull/25289#discussion_r2173909764


More information about the nio-dev mailing list