RFR: 4617681: constructor of BufferedImage throws unexpected IllegalArgumentException

Phil Race prr at openjdk.org
Sun Oct 5 20:39:21 UTC 2025


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

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

Commit messages:
 - 4617681

Changes: https://git.openjdk.org/jdk/pull/27640/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27640&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-4617681
  Stats: 192 lines in 2 files changed: 185 ins; 7 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/27640.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/27640/head:pull/27640

PR: https://git.openjdk.org/jdk/pull/27640


More information about the client-libs-dev mailing list