On Fri, 10 Oct 2025 22:30:53 GMT, Phil Race <[email protected]> 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
src/java.desktop/share/classes/java/awt/image/BandedSampleModel.java line 450:
> 448:
> 449: if (x < 0 || w < 0 || x >= width || w > width || x1 < 0 || x1 >
> width ||
> 450: y < 0 || h < 0 || y >= height || h > height || y1 < 0 || y1
> > height)
Suggestion:
y < 0 || h < 0 || y >= height || h > height || y1 < 0 || y1 >
height)
src/java.desktop/share/classes/java/awt/image/BandedSampleModel.java line 703:
> 701:
> 702: if (x < 0 || w < 0 || x >= width || w > width || x1 < 0 || x1 >
> width ||
> 703: y < 0 || h < 0 || y >= height || h > height || y1 < 0 || y1
> > height)
Suggestion:
y < 0 || h < 0 || y >= height || h > height || y1 < 0 || y1 >
height)
src/java.desktop/share/classes/java/awt/image/ComponentSampleModel.java line
747:
> 745:
> 746: if (x < 0 || (w < 0) || x >= width || w > width || x1 < 0 || x1
> > width ||
> 747: y < 0 || (h < 0) || y >= height || y > height || y1 < 0 ||
> y1 > height)
Suggestion:
y < 0 || (h < 0) || y >= height || y > height || y1 < 0 || y1 >
height)
src/java.desktop/share/classes/java/awt/image/ComponentSampleModel.java line
1002:
> 1000:
> 1001: if (x < 0 || w < 0 || x >= width || w > width || x1 < 0 || x1 >
> width ||
> 1002: y < 0 || h < 0 || y >= height || h > height || y1 < 0 || y1
> > height)
Suggestion:
y < 0 || h < 0 || y >= height || h > height || y1 < 0 || y1 >
height)
src/java.desktop/share/classes/java/awt/image/SinglePixelPackedSampleModel.java
line 460:
> 458:
> 459: if (x < 0 || w < 0 || x >= width || w > width || x1 < 0 || x1 >
> width ||
> 460: y < 0 || h < 0 || y >= height || h > height || y1 < 0 || y1
> > height)
Suggestion:
y < 0 || h < 0 || y >= height || h > height || y1 < 0 || y1 >
height)
src/java.desktop/share/classes/java/awt/image/SinglePixelPackedSampleModel.java
line 640:
> 638:
> 639: if (x < 0 || w < 0 || x >= width || w > width || x1 < 0 || x1 >
> width ||
> 640: y < 0 || h < 0 || y >= height || h > height || y1 < 0 || y1
> > height)
Suggestion:
y < 0 || h < 0 || y >= height || h > height || y1 < 0 || y1 >
height)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27754#discussion_r2431696072
PR Review Comment: https://git.openjdk.org/jdk/pull/27754#discussion_r2431696556
PR Review Comment: https://git.openjdk.org/jdk/pull/27754#discussion_r2431695064
PR Review Comment: https://git.openjdk.org/jdk/pull/27754#discussion_r2431695539
PR Review Comment: https://git.openjdk.org/jdk/pull/27754#discussion_r2431693595
PR Review Comment: https://git.openjdk.org/jdk/pull/27754#discussion_r2431694243