On Fri, 25 Jul 2025 03:36:44 GMT, Prasanta Sadhukhan <[email protected]>
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..
>
> Prasanta Sadhukhan has updated the pull request incrementally with one
> additional commit since the last revision:
>
> Use code tag and update test
test/jdk/javax/swing/ImageIcon/ImageIconTest.java line 42:
> 40:
> 41: static enum ArgType { FILE, URL, BYTEARRAY, IMAGE };
> 42: static enum ArgVal { NULL, INVALIDDATA };
Maybe name this `INVALID_DATA`:
Suggestion:
static enum ArgVal { NULL, INVALID_DATA };
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2230870538