RFR: 8361610: Avoid wasted work in ImageIcon(Image) for setting description

Alexander Zuev kizune at openjdk.org
Thu Aug 21 04:50:50 UTC 2025


On Thu, 21 Aug 2025 02:30:11 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> The `ImageIcon(Image)` constructor sets the description field to the value of "comment" property if it's a string. The `ImageIcon(Image, String)` constructor calls ImageIcon(Image). Since the two-parameter constructor explicitly provides the value for the description field, the implicitly set value for description is immediately overwritten, which is wasted work. 
> 
> Fix is to let `ImageIcon(Image, String) `constructor do the actual work of setting the fields and loading the image

LGTM

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

Marked as reviewed by kizune (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/26873#pullrequestreview-3139009152


More information about the client-libs-dev mailing list