On Wed, 16 Jun 2021 08:08:47 GMT, Yi Yang <yy...@openjdk.org> 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.

I looked through the changes in java.base and only spotted one case where a 
different (and more specific) exception is thrown.

The changes to to files in java.util.zip lead to annoying long lines so would 
be good to fix all those.

src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 471:

> 469:      */
> 470:     public int offsetByCodePoints(int index, int codePointOffset) {
> 471:         checkOffset(index, count);

String.offsetByCodePoints is specified to throw IOOBE. checkOffset may throw 
the more specific StringIndexOutOfBoundsException. That's a compatible change 
but I worry that we might want to throw the less specific exception in the 
further because code. I only mention is because there have been cases in 
java.lang where IOOBE was specified and AIOOBE by the implementation and it has 
been problematic to touch the implementation as a result.

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 to split this really long line to avoid inconsistent line length in 
this source file.

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

PR: https://git.openjdk.java.net/jdk/pull/4507

Reply via email to