RFR: 8159055: Clarify handling of null and invalid image data for ImageIcon constructors and setImage method [v25]
Phil Race
prr at openjdk.org
Tue Aug 5 18:47:13 UTC 2025
On Tue, 5 Aug 2025 13:39:39 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> src/java.desktop/share/classes/javax/swing/ImageIcon.java line 71:
>>
>>> 69: * even though {@link #getImage()} will return a non-null value,
>>> 70: * as the image will have no dimensions
>>> 71: * and {@link #getImageLoadStatus()} will report {@code MediaTracker.ERRORED}.
>>
>> What do you think about this version?
>> Suggestion:
>>
>> * If the image source parameter provided to a constructor or method is non-{@code null}
>> * but does not reference valid or accessible image data, no exceptions will be thrown.
>> * In this case, {@link #getImage()} will return a non-{@code null} value, but the image
>> * will have no dimensions, and nothing will be rendered.
>> * Additionally, {@link #getImageLoadStatus()} will report {@code MediaTracker.ERRORED}.
>>
>> Shorter sentences are easier to read, the statements are clearer.
>
> @prrace What do you say about the above suggestion?
I prefer one sentence because these aren't disjoint statements.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2255071686
More information about the client-libs-dev
mailing list