RFR: 8159055: ImageIcon.setImage can't handle null parameter [v5]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Mon Jun 16 15:24:48 UTC 2025
On Mon, 16 Jun 2025 15:01:37 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Fix for constructor
>
> src/java.desktop/share/classes/javax/swing/ImageIcon.java line 224:
>
>> 222: * @see java.awt.Image#getProperty
>> 223: */
>> 224: public ImageIcon (Image image) {
>
> Does it make sense to expand the javadoc for all the constructors to specify how `null` is handled?
I have expanded for those methods where there is code change for NULL interception....Not sure about others..
> src/java.desktop/share/classes/javax/swing/ImageIcon.java line 380:
>
>> 378: if (image == null) {
>> 379: return;
>> 380: }
>
> Should `setImage` clear / update the description automatically?
>
> It's up for discussion… What do you think?
Update the description from where? Its not overridden method..
> test/jdk/javax/swing/ImageIcon/ImageIconNullImageTest.java line 40:
>
>> 38: // Setting null image shouldn't cause NPE
>> 39: icon.setImage(null);
>> 40: }
>
> Add the test for `new ImageIcon((Image) null)`: currently it throws `NullPointerException` but it won't throw it after your fix.
ok
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2150276928
PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2150282841
PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2150277162
More information about the client-libs-dev
mailing list