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

Kim Barrett kbarrett at openjdk.org
Mon May 19 20:18:54 UTC 2025


On Mon, 19 May 2025 18:30:45 GMT, ExE Boss <duke at openjdk.org> wrote:

>> Kim Barrett has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   move jdk.internal.nio.Cleaner to sun.nio
>
> src/java.base/share/classes/java/nio/Bits.java line 145:
> 
>> 143:                         // Increment with overflow to 0, so the value can
>> 144:                         // never equal the initial/reset cleanedEpoch value.
>> 145:                         RESERVE_GC_EPOCH = Integer.max(0, RESERVE_GC_EPOCH + 1);
> 
> Could also do the following which avoids the branch in `Integer.max`:
> Suggestion:
> 
>                         RESERVE_GC_EPOCH = (RESERVE_GC_EPOCH + 1) & Integer.MAX_VALUE;

I think the use of `Integer.max` is clearer, any performance difference is insignificant, and the compiler can
make that change as an optimization if appropriate. So I'm not inclined to accept this suggestion.

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

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


More information about the core-libs-dev mailing list