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

Alexey Ivanov aivanov at openjdk.org
Thu Jun 19 19:54:31 UTC 2025


On Thu, 19 Jun 2025 10:11:57 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Prasanta Sadhukhan has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Test fix
>>  - javadoc wording..clear image desscription if image is null
>
> src/java.desktop/share/classes/javax/swing/ImageIcon.java line 147:
> 
>> 145:         image = Toolkit.getDefaultToolkit().getImage(filename);
>> 146:         if (image == null) {
>> 147:             this.description = null;
> 
> I do not think we have to enforce setting `description` to `null` if the image is `null` — **it is up to the developer to decide**.

And this code is in constructor, therefore `description` still has its default value of `null`.

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

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


More information about the client-libs-dev mailing list