RFR: 6185110: Undefined behaviour of SampleModel for width, height < 0 [v6]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Wed Nov 26 03:27:50 UTC 2025
On Tue, 25 Nov 2025 22:59:06 GMT, Phil Race <prr at openjdk.org> wrote:
>> The only significant change here is to ensure that all SampleModel types throw a specified exception if a client
>> calls any of the following methods with a negative width or height.
>> getPixels(..)
>> setPixels(..)
>> getSamples(..)
>> setSamples(..)
>>
>> The rest is fixing the javadoc to properly describe what happens and some minor cleanup.
>> I use {@inheritDoc} to avoid repeating the super-class doc. And no one now has to tediously compare them.
>> I could just delete the javadoc but that would cause no javadoc to be generated for an overridden method.
>> There were a couple of surprises with {@inheritDoc} and the one I had to deal with is that declared RuntimeExceptions
>> are not inherited. You need to explicitly re-add them. This because if it isn't an exception in the method signature (as in foo() throws BarException), and instead you only have "@throws BarException" it will not be inherited.
>>
>> I added a test which verifies the behaviour for illegal arguments.
>>
>> CSR is here https://bugs.openjdk.org/browse/JDK-8369623
>
> Phil Race has updated the pull request incrementally with one additional commit since the last revision:
>
> 6185110
src/java.desktop/share/classes/java/awt/image/SampleModel.java line 534:
> 532: * @throws NullPointerException if {@code obj} or {@code data} is {@code null}.
> 533: * @throws ArrayIndexOutOfBoundsException if the coordinates are
> 534: * not in bounds, or if obj is too small to hold the input.
In some places {@code obj} is used, in some places it is not, like here and l583,
Maybe we can think of being consistent..
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27754#discussion_r2562806976
More information about the client-libs-dev
mailing list