On Thu, 12 Jun 2025 06:34:09 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 one > additional commit since the last revision: > > javadoc src/java.desktop/share/classes/javax/swing/ImageIcon.java line 374: > 372: */ > 373: public void setImage(Image image) { > 374: if (image == null) { don't we need to update the actual image icon of imageicon to null? similar to how constructor/and other methods works when they get "null-image"? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2143336731