RFR: 8354789: Unnecessary null check in sun.awt.windows.WToolkit.getFontPeer [v2]

Alexey Ivanov aivanov at openjdk.org
Wed Apr 16 13:14:45 UTC 2025


On Wed, 16 Apr 2025 13:06:27 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

>> There is redundant `null` comparison in `sun.awt.windows.WToolkit.getFontPeer`
>> Local variable `retval` can't be null after new object assignment.
>> https://github.com/openjdk/jdk/blob/24de9dee80738fe6ab1fc726b071546c85bbf79a/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java#L604-L605
>
> Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8354789: Unnecessary null check in sun.awt.windows.WToolkit.getFontPeer

Other than the minor nit, looks good to me.

src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java line 602:

> 600:                 return cachedVal;
> 601:             }
> 602:         }

Suggestion:

        }


I'd put a blank line here to separate the logic of fetching a cached value from putting a new value to the cache.

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

Marked as reviewed by aivanov (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/23150#pullrequestreview-2772482026
PR Review Comment: https://git.openjdk.org/jdk/pull/23150#discussion_r2046902864


More information about the client-libs-dev mailing list