RFR: 8268698: Use Objects.check{Index, FromToIndex, FromIndexSize} where possible [v2]

Yi Yang yyang at openjdk.java.net
Fri Jun 18 05:54:05 UTC 2021


On Thu, 17 Jun 2021 10:19:43 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Yi Yang has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   restore IndexOfOufBoundsException; split exception line
>
> 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 future. I only mention it 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.

Yes, changing the type of thrown exception may break something. And as David said, this also requires a CSR approval, which is a relatively long process, so I restored the original code.

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

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



More information about the security-dev mailing list