On Tue, 29 Jul 2025 14:13:39 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.. > > Prasanta Sadhukhan has updated the pull request incrementally with three > additional commits since the last revision: > > - Modify summary > - Modify summary > - Remove redundant fileName param > Currently, [JDK-8159055](https://bugs.openjdk.org/browse/JDK-8159055) is an > enhancement which made sense while the goal of this PR was to change > `Image.setImage` so that it accepts `null` as parameter. > > After a month of discussions, that solution has been abandoned, instead it is > stated that `Image.setImage` will throw `NullPointerException` if `image` > parameter is `null`. > > I think the type of JDK-8159055 should be changed to _bug_. I agree. Not saying how null is handled is a bug. So fixing it is a bug fix, not an enhancement. ------------- PR Comment: https://git.openjdk.org/jdk/pull/25767#issuecomment-3133333056