On Tue, 3 Mar 2026 22:38:37 GMT, Phil Race <[email protected]> wrote:
>> src/java.desktop/share/classes/java/awt/image/DataBuffer.java line 559:
>>
>>> 557:
>>> 558: // Checks used by subclass constructors.
>>> 559: static final void checkSize(int size) {
>>
>> Do we really need the `final` modifier for a static method? Static methods
>> aren't inherited.
>
> It doesn't cause any problems does it ?
No, it doesn't except for an IDE warning that's *not needed*.
>> src/java.desktop/share/classes/java/awt/image/DataBuffer.java line 579:
>>
>>> 577: static final void checkArraySize(int size, int offset, int
>>> arrayLen) {
>>> 578: if (size <= 0 || (size + offset) > arrayLen ||
>>> 579: (offset > 0) && ((size + offset) < size)) {
>>
>> Should the condition `(size + offset) > arrayLen` also ensure `offset > 0`?
>>
>> Suggestion:
>>
>> if (size <= 0 || offset < 0 || (size + offset) > arrayLen ||
>> (size + offset) < size) {
>
> No. offset is allowed to be negative.
How is `offset` allowed to be negative?
[The
specification](https://docs.oracle.com/en/java/javase/25/docs/api/java.desktop/java/awt/image/DataBuffer.html)
for `DataBuffer` states, _“Getting or setting the 0th element of a bank, uses
the (0+offset)th element of the array.”_ This statement implies the offset
cannot be negative.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29766#discussion_r2891406904
PR Review Comment: https://git.openjdk.org/jdk/pull/29766#discussion_r2891400769