RFR: 8159055: ImageIcon.setImage and ImageIcon(Image) constructor can't handle null parameter [v11]

Alexey Ivanov aivanov at openjdk.org
Thu Jul 3 09:28:44 UTC 2025


On Fri, 20 Jun 2025 11:55:35 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Remove resetting description from constructor as it is already null
>
> src/java.desktop/share/classes/javax/swing/ImageIcon.java line 230:
> 
>> 228:         if (image == null) {
>> 229:             return;
>> 230:         }
> 
> So, are we changing the constructors that accept `Image`?

Are we changing the constructor to accept `null` as the `Image` parameter?

There's [a long thread](https://github.com/openjdk/jdk/pull/25767/files#r2155610976) about *consistent* behaviour of the `ImageIcon` constructors, yet no decision has been taken.

@prrace mentioned consistency among constructors, and `ImageIcon` constructors consistently throw `NullPointerException` for `null` image. In fact, he referred to setting the `description` field, but this is moot if a constructor throws.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2182302073


More information about the client-libs-dev mailing list