On Tue, 16 Jun 2026 22:06:20 GMT, Phil Race <[email protected]> wrote:

>> In JDK 26 the spec for various methods in Raster were updated under 
>> https://bugs.openjdk.org/browse/JDK-8369129
>> 
>> It was discovered that some cases did not actually check an out-of-bounds 
>> bank index as specified
>> There was a test for two of these cases but there was a bug which caused it 
>> to get the expected exception for a different reason.
>> 
>> The implementation and the test are fixed.
>> 
>> 
>> 
>> ---------
>> - [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:
> 
>   8386671

There is an inconsistency here:

https://github.com/prrace/jdk/blob/abb512a0e1c65743358c4c2319b40cb15bb85487/src/java.desktop/share/classes/java/awt/image/Raster.java#L275-L307


 * @throws IllegalArgumentException if {@code scanlineStride}
 *         is less than or equal to 0
 * @throws IllegalArgumentException if {@code pixelStride} is less than or 
equal to 0
 
 ...
 
  public static WritableRaster createInterleavedRaster(int dataType,
                                                     int w, int h,
                                                     int scanlineStride,
                                                     int pixelStride,
                                                     int[] bandOffsets,
                                                     Point location) {
                                                  
 ...
 
if (pixelStride <= 0) {
    throw new IllegalArgumentException("pixelStride is <= 0");
}
if (scanlineStride <= 0) {
    throw new IllegalArgumentException("scanlineStride is <= 0");
}


https://github.com/prrace/jdk/blob/abb512a0e1c65743358c4c2319b40cb15bb85487/src/java.desktop/share/classes/java/awt/image/Raster.java#L795-L818


 * @throws IllegalArgumentException if {@code scanlineStride}
 *         is less than 0
 * @throws IllegalArgumentException if {@code pixelStride} is less than 0

...

public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer,
                                                     int w, int h,
                                                     int scanlineStride,
                                                     int pixelStride,
                                                     int[] bandOffsets,
                                                     Point location)
...

    if (pixelStride <= 0) {
        throw new IllegalArgumentException("pixelStride is <= 0");
    }
    if (scanlineStride <= 0) {
        throw new IllegalArgumentException("scanlineStride is <= 0");
    }



Note that the `<= 0` check contradicts the doc stating `less than 0`.



https://github.com/prrace/jdk/blob/abb512a0e1c65743358c4c2319b40cb15bb85487/src/java.desktop/share/classes/java/awt/image/Raster.java#L446-L472


 * @throws IllegalArgumentException if {@code scanlineStride}
 *         is less than 0

public static WritableRaster createBandedRaster(int dataType,
                                                int w, int h,
                                                int scanlineStride,
                                                int[] bankIndices,
                                                int[] bandOffsets,
                                                Point location) {
    if (scanlineStride < 0) {
        throw new IllegalArgumentException("Scanline stride must be >= 0");
    }


Here, `scanlineStride == 0` is allowed.

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

PR Review: https://git.openjdk.org/jdk/pull/31540#pullrequestreview-4544494833

Reply via email to