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

Alexey Ivanov aivanov at openjdk.org
Mon Aug 25 10:08:59 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

Marked as reviewed by aivanov (Reviewer).

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

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


More information about the client-libs-dev mailing list