RFR: 6753661: JFileChooser font not reset after Look & Feel change [v6]

Alexey Ivanov aivanov at openjdk.org
Fri Feb 10 17:12:24 UTC 2023


On Fri, 10 Feb 2023 16:58:02 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> test/jdk/javax/swing/JFileChooser/JFileChooserFontReset.java line 70:
>> 
>>> 68:                     System.out.println("current font " + curFont);
>>> 69:                     if ((curFont != null && !curFont.equals(origFont)) ||
>>> 70:                         (origFont != null && !origFont.equals(curFont))) {
>> 
>> The newly added condition is redundant because `origFont.equals(curFont) == curFont.equals(origFont)`. (It's possible `equals` returns different values but it violates its contract then.)
>
> I dont think it's redundant..There's a || check in between
> 
> If `curFont `is not null and `origFont `is null, then 1st condition `curFont != null && !curFont.equals(origFont)` is satisfied and it will throw exception
> 
> If `origFont `is not null and `curFont `is null, then 1st condition `curFont != null && !curFont.equals(origFont)` is not satisfied and 2nd condition `origFont != null && !origFont.equals(curFont)` is satisfied and it will throw exception. If we remove origFont.equals(curFont) check, it will not check the fix..

`curFont != origFont && (curFont != null && !curFont.equals(origFont))`

The first part catches the case where both are null.

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

PR: https://git.openjdk.org/jdk/pull/12180



More information about the client-libs-dev mailing list