On Thu, 17 Jun 2021 10:21:35 GMT, Alan Bateman <[email protected]> wrote:
>> After JDK-8265518(#3615), it's possible to replace all variants of
>> checkIndex by
>> Objects.checkIndex/Objects.checkFromToIndex/Objects.checkFromIndexSize in
>> the whole JDK codebase.
>
> src/java.base/share/classes/java/util/Base64.java line 934:
>
>> 932: if (closed)
>> 933: throw new IOException("Stream is closed");
>> 934: Preconditions.checkFromIndexSize(len, off, b.length, (xa,
>> xb) -> new ArrayIndexOutOfBoundsException());
>
> You might want to split this really long line too, to avoid inconsistent line
> length in this source file.
I would suggest factoring out `(xa, xb) -> new
ArrayIndexOutOfBoundsException()` as a reusable component on `Preconditions`,
and maybe even supplying an exception message (since it is rather useful, and
way better than no message).
See the usages of `Preconditions.outOfBoundsExceptionFormatter` (where there
just happens to be many repeated cases of supplying AIOOBE with a message, that
could also be consolidated, separate fix perhaps).
-------------
PR: https://git.openjdk.java.net/jdk/pull/4507