On Fri, 24 Apr 2026 18:29:57 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 169: > 167: } > 168: if (scanlineStride <= 0) { > 169: throw new IllegalArgumentException("scanlineStride must be > > 0"); This `scanlineStride <= 0` check is not documented in the spec. And it seems is not triggered by the test. src/java.desktop/share/classes/java/awt/image/MultiPixelPackedSampleModel.java line 173: > 171: int dataTypeSize = DataBuffer.getDataTypeSize(dataType); > 172: if ((((numberOfBits * (long)w) + dataTypeSize - 1) / > dataTypeSize) > scanlineStride) { > 173: throw new RasterFormatException("scanlineStride is too small > for width"); The new spec uses a different code to describe when the RasterFormatException is occurred: >{@code (numberOfBits * w) / DataBuffer.getDataTypeSize(dataType)} is greater >than {@code scanlineStride} src/java.desktop/share/classes/java/awt/image/MultiPixelPackedSampleModel.java line 334: > 332: */ > 333: public SampleModel createSubsetSampleModel(int[] bands) { > 334: if (bands != null) { Do we need to cover this by the test? test/jdk/java/awt/image/MultiPixelPackedSampleModelConstructor.java line 24: > 22: */ > 23: > 24: import static java.awt.image.DataBuffer.*; Usually static imports are placed last with one empty line between non-static and static imports. "*" can be replaced with the specific classes. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/30826#discussion_r3244522880 PR Review Comment: https://git.openjdk.org/jdk/pull/30826#discussion_r3244536240 PR Review Comment: https://git.openjdk.org/jdk/pull/30826#discussion_r3244525949 PR Review Comment: https://git.openjdk.org/jdk/pull/30826#discussion_r3244554150
