On Mon, 20 Apr 2026 23:56:03 GMT, Phil Race <[email protected]> wrote:

>> The bug was filed to note that the constructor for 
>> MultiPixelPackedSampleModel could throw an odd exception if numberOfBits is 
>> zero.
>> Per the spec this should throw RasterFormatException.
>> 
>> 
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Phil Race has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   8381007

src/java.desktop/share/classes/java/awt/image/MultiPixelPackedSampleModel.java 
line 349:

> 347:      * {@code MultiPixelPackedSampleModel} only has one band, the
> 348:      * bands argument is ignored.
> 349:      * @param bands the specified bands (ignored)

I noticed this very odd spec and implementation.
* null bands is silently ignored
* but if you supply it, it must have length one
* but then it doesn't check the condition that the single referenced band is 
zero.
* bizarrely it says it will throw IAE for parameters that don't exist

I decided that like getSampleSize(int band) it should say it completely ignore 
the band-related argument. This seems unlikely to affect anyone except an app 
that really wanted a RasterFormatException (!)
Also the spurious throws clause is removed

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30826#discussion_r3114278664

Reply via email to