RFR: 6185110: Undefined behaviour of SampleModel for width, height < 0 [v3]

Phil Race prr at openjdk.org
Mon Nov 24 20:40:17 UTC 2025


On Mon, 3 Nov 2025 07:23:06 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> 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/BandedSampleModel.java line 603:
> 
>> 601:      * @param data      The DataBuffer containing the image data
>> 602:      * @see #getDataElements(int, int, Object, DataBuffer)
>> 603:      * @throws NullPointerException if {@code data} is null.
> 
> I guess we will get NPE if (@code obj] is also null...Shouldn't we specify that too?

I updated this as you can see.

> src/java.desktop/share/classes/java/awt/image/ComponentSampleModel.java line 901:
> 
>> 899:      * @param data      the DataBuffer containing the image data
>> 900:      * @see #getDataElements(int, int, Object, DataBuffer)
>> 901:      * @throws NullPointerException if {@code data} is null.
> 
> same here

I updated this as you can see.

> src/java.desktop/share/classes/java/awt/image/MultiPixelPackedSampleModel.java line 597:
> 
>> 595:      * @param data the {@code DataBuffer} containing the image data
>> 596:      * @see #getDataElements(int, int, Object, DataBuffer)
>> 597:      * @throws NullPointerException if {@code data} is null.
> 
> here too

I updated this as you can see.

> src/java.desktop/share/classes/java/awt/image/MultiPixelPackedSampleModel.java line 650:
> 
>> 648:      * @param data the {@code DataBuffer} containing the image data
>> 649:      * @see #getPixel(int, int, int[], DataBuffer)
>> 650:      * @throws NullPointerException if {@code data} is null.
> 
> here NPE can be thrown if iArray is null...maybe we should mention that in spec too..

Looks like this is the one case that missed saying that.

> src/java.desktop/share/classes/java/awt/image/SinglePixelPackedSampleModel.java line 571:
> 
>> 569:      * @param data      The DataBuffer containing the image data.
>> 570:      * @see #getDataElements(int, int, Object, DataBuffer)
>> 571:      * @throws NullPointerException if {@code data} is null.
> 
> same...NPE for null obj?

I updated this as you can see.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27754#discussion_r2551178466
PR Review Comment: https://git.openjdk.org/jdk/pull/27754#discussion_r2551178742
PR Review Comment: https://git.openjdk.org/jdk/pull/27754#discussion_r2551181012
PR Review Comment: https://git.openjdk.org/jdk/pull/27754#discussion_r2557652512
PR Review Comment: https://git.openjdk.org/jdk/pull/27754#discussion_r2551179238


More information about the client-libs-dev mailing list