RFR: 8361715: (bf) Improve java/nio/Buffer/GetChars.java and migrate to JUnit [v7]
Brett Okken
duke at openjdk.org
Sat Jul 19 01:54:14 UTC 2025
On Fri, 18 Jul 2025 22:27:35 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Brett Okken has updated the pull request incrementally with one additional commit since the last revision:
>>
>> adjust indexes used in tests to accomodate random values
>
> test/jdk/java/nio/Buffer/CharBufferAsCharSequenceTest.java line 53:
>
>> 51:
>> 52: private static final Random RAND = RandomFactory.getRandom();
>> 53: private static final int SIZE = 128 + RAND.nextInt(1024);
>
> You might want to use the two-arg [nextInt](https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/util/random/RandomGenerator.html#nextInt(int,int)) here instead of an addition, e.g., `RAND.nextInt(128,1152)`.
done
https://github.com/openjdk/jdk/pull/26282/commits/394832a472a03dc015ab857a679506b4e8ca34e6
> test/jdk/java/nio/Buffer/CharBufferAsCharSequenceTest.java line 66:
>
>> 64: int mid = cb.capacity() >>> 1;
>> 65: int start = RAND.nextInt(mid + 1); // from 0 to mid
>> 66: int end = mid + RAND.nextInt(cb.capacity() - mid + 1); // from mid to capacity
>
> Same comment as above concerning the two-arg `nextInt`.
done - also made sure there is a minimum "remaining" between position and limit
https://github.com/openjdk/jdk/pull/26282/commits/394832a472a03dc015ab857a679506b4e8ca34e6
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26282#discussion_r2217089822
PR Review Comment: https://git.openjdk.org/jdk/pull/26282#discussion_r2217090104
More information about the nio-dev
mailing list