RFR: 8159055: ImageIcon.setImage can't handle null parameter [v19]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Sun Jul 27 07:02:16 UTC 2025
On Fri, 25 Jul 2025 19:20:22 GMT, Phil Race <prr at openjdk.org> wrote:
>> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Use code tag and update test
>
> src/java.desktop/share/classes/javax/swing/ImageIcon.java line 66:
>
>> 64: * If the image source parameter to a constructor or method is non-null,
>> 65: * but does not reference valid accessible image data,
>> 66: * no exceptions will be thrown but the image will be 'effectively' null,
>
> Joe asked for if there's an alternative to 'effectively' null. I'm open to suggestions. "unset" ?
"unset" sounded better..modified..
> src/java.desktop/share/classes/javax/swing/ImageIcon.java line 184:
>
>> 182: * be preloaded by using MediaTracker to monitor the loaded state
>> 183: * of the image.
>> 184: * Passing {@code null} URL will result in {@code NullPointerException}.
>
> In the CSR, Joe quite reasonably requested that these all become @throws clauses
ok..done..
> test/jdk/javax/swing/ImageIcon/ImageIconTest.java line 117:
>
>> 115: ii.setImage((Image)null);
>> 116: throw new RuntimeException("No NPE");
>> 117: } catch (NullPointerException e) {
>
> It occurred to me that you could include this in the switch with a new ARGTYPE of "SETIMAGE".
> Bit of a misnomer as its the type + the method but then you can also check the non-null invalid data type.
ok..moved..
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2233797122
PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2233795231
PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2233795998
More information about the client-libs-dev
mailing list