On Thu, 12 Jun 2025 03:23:30 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> wrote:
> When trying to call 'icon.setImage(null);' where 'icon' is an instance of > ImageIcon, a null pointer exception is thrown at runtime. > The code tried to get the `id` for that image and instantiates `MediaTracker` > to associate the null image to that `id` and checks the status of loading > this null image, removes the null image from the tracker and then tries to > get the image width where it throws NPE as image is null. > > It's better to not go through all MediaTracker usage and bail out initially > itself for null image.. This pull request has now been integrated. Changeset: 98e64cff Author: Prasanta Sadhukhan <psadhuk...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/98e64cffff24ec8b8abeb7afd121e58bc53ed034 Stats: 165 lines in 2 files changed: 165 ins; 0 del; 0 mod 8159055: Clarify handling of null and invalid image data for ImageIcon constructors and setImage method Reviewed-by: aivanov, prr, abhiscxk, kizune, serb ------------- PR: https://git.openjdk.org/jdk/pull/25767