RFR: 8377568: DataBuffer constructors and methods do not specify required exceptions [v3]
Phil Race
prr at openjdk.org
Tue Feb 17 22:04:52 UTC 2026
On Tue, 17 Feb 2026 21:05:39 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> Phil Race has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8377568
>
> src/java.desktop/share/classes/java/awt/image/DataBuffer.java line 555:
>
>> 553: throw new ArrayIndexOutOfBoundsException("Invalid index (bankOffset+i) is " +
>> 554: "(" + offsets[bank] + " + " + i + ") which is too large for size : " + size);
>> 555: }
>
> Suggestion:
>
> if ((i + offsets[bank]) >= size) {
> throw new ArrayIndexOutOfBoundsException("Invalid index (bankOffset+i) is " +
> "(" + offsets[bank] + " + " + i + ") which is too large for size : " + size);
> }
>
> Wrong indentation.
It may not be what you meant but I changed it to 4.
> src/java.desktop/share/classes/java/awt/image/DataBufferByte.java line 74:
>
>> 72: *
>> 73: * @param size The size of the {@code DataBuffer}.
>> 74: * throw IllegalArgumentException if {@code size} is less than zero.
>
> Suggestion:
>
> * @throws IllegalArgumentException if {@code size} is less than zero
>
> You have to use `@throws` javadoc tag. Usually, `@throws` descriptions don't have a full stop.
>
> https://github.com/openjdk/jdk/blob/4ab05d25c170036cd85155c45e58930fedf614a4/src/java.desktop/share/classes/java/awt/image/DataBuffer.java#L117-L118
I fixed this.
> src/java.desktop/share/classes/java/awt/image/DataBufferByte.java line 93:
>
>> 91: * @param numBanks The number of banks in the {@code DataBuffer}.
>> 92: * throw IllegalArgumentException if {@code size} is less than zero,
>> 93: * or {@code numBanks} is less than one
>
> Suggestion:
>
> * @throws IllegalArgumentException if {@code size} is less than zero,
> * or {@code numBanks} is less than one
fixed
> src/java.desktop/share/classes/java/awt/image/DataBufferByte.java line 159:
>
>> 157: * throw NullPointerException if {@code dataArray} is {@code null}.
>> 158: * throw IllegalArgumentException if {@code size} is less than zero,
>> 159: * or {@code (offset + size)} is greater than the length of {@code dataArray}
>
> Suggestion:
>
> * @throws NullPointerException if {@code dataArray} is {@code null}
> * @throws IllegalArgumentException if {@code size} is less than zero,
> * or {@code (offset + size)} is greater than the length of {@code dataArray}
fixed
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29766#discussion_r2819282173
PR Review Comment: https://git.openjdk.org/jdk/pull/29766#discussion_r2819284940
PR Review Comment: https://git.openjdk.org/jdk/pull/29766#discussion_r2819286298
PR Review Comment: https://git.openjdk.org/jdk/pull/29766#discussion_r2819285624
More information about the client-libs-dev
mailing list