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

Prasanta Sadhukhan psadhukhan at openjdk.org
Thu Jun 19 04:38:01 UTC 2025


On Thu, 19 Jun 2025 04:12:25 GMT, ExE Boss <duke 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;
> 
> Suggestion:

We dont know the exact order of setDescription call..If that is called before setImage or constructor (unlikely but can be called), the description would not be null, so it's better to clear the description for null image to be safe..

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

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


More information about the client-libs-dev mailing list