On Sat, 27 Nov 2021 16:37:03 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

>> Updated code checks both non-null and instance of a class in java.desktop 
>> module classes.
>> The checks and explicit casts could also be replaced with pattern matching 
>> for the instanceof operator. 
>> Similar cleanups
>> 1. [JDK-8273484](https://bugs.openjdk.java.net/browse/JDK-8273484) 
>> java.naming
>> 2. [JDK-8258422](https://bugs.openjdk.java.net/browse/JDK-8258422) java.base
>
> src/java.desktop/macosx/classes/com/apple/laf/AquaRootPaneUI.java line 78:
> 
>> 76:         final Component parent = c.getParent();
>> 77: 
>> 78:         if (parent instanceof JFrame frameParent) {
> 
> The `frameParent` variable was declared `final` before.
> Suggestion:
> 
>         if (parent instanceof final JFrame frameParent) {

Does it really worth keeping `final` here?
In my opinion it makes code unnecessary longer and harder to read in this case

> src/java.desktop/unix/classes/sun/awt/X11/XWindow.java line 312:
> 
>> 310:         }
>> 311: 
>> 312:         return window.getContentWindow();
> 
> Is the branch where 0 was returned impossible?

Yes. It was impossible.
Only way out of this cycle is when `peer instanceof XWindow` is `true`
https://github.com/openjdk/jdk/blob/0c7a4b8aa8bb672e87aae7090494719db018b9b1/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java#L306-L310

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

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

Reply via email to