RFR: 8377568: DataBuffer constructors and methods do not specify required exceptions [v3]
Alexey Ivanov
aivanov at openjdk.org
Tue Feb 17 22:13:04 UTC 2026
On Tue, 17 Feb 2026 22:04:50 GMT, Phil Race <prr at openjdk.org> wrote:
>> This fix updates DataBuffer subclasses to actually adhere to their stated specifications by rejecting certain invalid parameters for constructors and getters and setters.
>> A new egression test for each of the constructor and getter/setter cases is supplied.
>>
>> No existing regression tests fail with this change, and standard demos work.
>>
>> Problems caused by these changes are most likely to occur if the client has a bug such that
>> - a client uses the constructors that accept an array and then supplies a "size" that is greater than the array.
>> - a client uses the constructors that accept an array and then supplies a "size" that is less than the array and then uses getter/setters that are within the array but outside the range specified by size.
>>
>> Since very few clients (and just one case in the JDK that I found) even use these array constructors the changes are unlikely to make a difference to clients.
>>
>> A CSR will be submitted.
>
> 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: }
No, it wasn't what I meant. The `throw` statement should be indented by 4 spaces—now there are 6 spaces. The continuation lines should be indented by 8 spaces, but there were 7. This is the recommendation from the [Java Style Guide for Indentation](https://www.oracle.com/java/technologies/javase/codeconventions-indentation.html).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29766#discussion_r2819317188
More information about the client-libs-dev
mailing list