RFR: 4617681: constructor of BufferedImage throws unexpected IllegalArgumentException
Damon Nguyen
dnguyen at openjdk.org
Wed Nov 26 18:26:53 UTC 2025
On Sun, 5 Oct 2025 20:33:26 GMT, Phil Race <prr at openjdk.org> wrote:
> Specifying the behaviour of BufferedImage constructors for invalid dimensions is long overdue.
>
> The behaviour for image types and sizes <= 0 is unchanged by this PR.
> Also in many cases the behaviour for sizes that are too large is also unchanged.
> In some cases, the behaviour is changed from "accidental" NegativeArraySizeException to a consistent IllegalArgumentException.
>
> In no case is anything changed that would affect the possibility to construct a BufferedImage.
>
> A test is provided to ensure the behaviour.
>
> A CSR is provided too : https://bugs.openjdk.org/browse/JDK-8369155
src/java.desktop/share/classes/java/awt/image/BufferedImage.java line 345:
> 343: "width " + width + " height " + height + " overflow int");
> 344: }
> 345: /* most BufferedImage formats use one data buffer element per pixel.
Suggestion:
/* Most BufferedImage formats use one data buffer element per pixel.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27640#discussion_r2566071669
More information about the client-libs-dev
mailing list