RFR: 6742362: JComponent.setFont() font comparison is not correct

Dmitry Markov dmarkov at openjdk.java.net
Tue Feb 22 14:24:53 UTC 2022


On Tue, 22 Feb 2022 08:59:52 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> Font comparison in JComponent.setFont() uses `font != oldFont` check which is not correct as per Object equality essence. The correct way of checking font equality is to use "equals" as is done in [GlyphLayout](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/font/GlyphLayout.java#L144) , [StandardGlyphVector](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/font/StandardGlyphVector.java#L657) etc
> 
> Existing jtreg, jck test are green.

I have concern regarding the case once null-value is passed to `setFont() `method. In particular when `font` is null but `oldFont` is not null. Now `revalidate()` and `repaint()` are not called but they used to be called before.
Shouldn't we have here something similar to https://github.com/openjdk/jdk/blob/b48e71f16a01992500851e3eb56c90b0ba0668e4/src/java.desktop/share/classes/java/awt/Container.java#L1782

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

Changes requested by dmarkov (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/7571



More information about the client-libs-dev mailing list