RFR: 8159055: Clarify handling of null and invalid image data for ImageIcon constructors and setImage method [v26]
Alexey Ivanov
aivanov at openjdk.org
Wed Aug 6 15:04:17 UTC 2025
On Wed, 6 Aug 2025 02:58:01 GMT, Prasanta Sadhukhan <psadhukhan at 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..
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>
> Test update
Looks good… except for lots of unexpected blank lines in the test code.
test/jdk/javax/swing/ImageIcon/ImageIconTest.java line 73:
> 71: break;
> 72:
> 73: case URL :
Was adding so many blank lines intentional?
-------------
Marked as reviewed by aivanov (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/25767#pullrequestreview-3093086116
PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2257484753
More information about the client-libs-dev
mailing list