RFR: 8299982: (bf) Buffer.checkIndex(int, int) should use Preconditions.checkIndex(int, int, BiFunction) [v2]
Brian Burkhalter
bpb at openjdk.org
Thu Jan 26 18:52:46 UTC 2023
On Thu, 26 Jan 2023 17:48:46 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>>> Hmm, maybe start out simple with a constant, otherwise this change is going to require much wider startup and performance testing.
>>
>> Something like?
>>
>> @ForceInline
>> final int checkIndex(int i, int nb) { // package-private
>> return Preconditions.checkIndex(i, limit - nb + 1,
>> (x, y) -> new IndexOutOfBoundsException());
>> }
>
>> In the original code it just has `throw new IndexOutOfBoundsException();`, so why not make it non-capturing lambda by just returning the same, e.g., `(x, y) -> new IndexOutOfBoundsException()`
>
> We were trying to improve the message but it looks like it is not worth it.
Exception formatter changed to a constant in e4ba71731f806897144a90714a72cdd8516df1d2.
-------------
PR: https://git.openjdk.org/jdk/pull/12174
More information about the nio-dev
mailing list