On Thu, 22 Jul 2021 06:23:43 GMT, Yi Yang <yy...@openjdk.org> wrote:

>> test/jdk/javax/imageio/ImageReaderReadAll.java line 94:
>> 
>>> 92:             if (seekForwardOnly) {
>>> 93:                 if (imageIndex < minIndex)
>>> 94:                     throw new IndexOutOfBoundsException();
>> 
>> Can't we use checkFromToIndex​ for this IOOBE too? Used in many other places 
>> in this PR...
>> 
>> Please also confirm all tests modified are green after this modification..
>
> checkFromToIndex​ has different semantice with checkIndex:
> 
> - checkFromToIndex
> 
>      * <ul>
>      *  <li>{@code fromIndex < 0}</li>
>      *  <li>{@code fromIndex > toIndex}</li>
>      *  <li>{@code toIndex > length}</li>
>      *  <li>{@code length < 0}, which is implied from the former 
> inequalities</li>
>      * </ul>
> 
> - checkIndex
> 
>      * <ul>
>      *  <li>{@code index < 0}</li>
>      *  <li>{@code index >= length}</li>
>      *  <li>{@code length < 0}, which is implied from the former 
> inequalities</li>
>      * </ul>
> 
> ---
> 
> The following tests are passed after applying this patch:
> 
> test/jdk/javax/imageio/AppletResourceTest.java
> test/jdk/javax/imageio/ImageReaderReadAll.java
> test/jdk/javax/imageio/metadata/IIOMetadataFormat/UserPluginMetadataFormatTest.java
> 
> 
> ClippedImages.java is a manual test, I have no environment to test it, but 
> since it's a trivial replacement, I think it's okay..

I meant 

if (imageIndex < minIndex)
                    throw new IndexOutOfBoundsException();

can't it be replaced with Objects.checkFromToIndex(minIndex, imageIndex, ..

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

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

Reply via email to