[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    Integrated: 8289126: Cleanup unnecessary null comparison before instanceof check in jdk.hotspot.agen
From:       Andrey Turbanov <aturbanov () openjdk ! org>
Date:       2022-06-27 7:32:57
Message-ID: rPqqbcs_oP_RQ2vRBik5viT-R8o5QjwyFJEoa4YwAEw=.689b29d0-a8a3-4021-b9c8-0ee79b9e1ea5 () github ! com
[Download RAW message or body]

On Fri, 24 Jun 2022 09:19:33 GMT, Andrey Turbanov <aturbanov@openjdk.org> wrote:

> Update code checks both non-null and instance of a class in jdk.hotspot.agent module classes.
> The checks and explicit casts could also be replaced with pattern matching for the instanceof operator.
> 
> For example, the following code:
> 
>               Object node = tree.getLastSelectedPathComponent();
>               if (node != null && node instanceof SimpleTreeNode) {
>                 showInspector((SimpleTreeNode)node);
>               }
> 
> Can be simplified to:
> 
>               Object node = tree.getLastSelectedPathComponent();
>               if (node instanceof SimpleTreeNode simpleNode) {
>                 showInspector(simpleNode);
>               }
> 
> 
> See similar cleanup in java.base - [JDK-8258422](https://bugs.openjdk.java.net/browse/JDK-8258422)

This pull request has now been integrated.

Changeset: 7905788e
Author:    Andrey Turbanov <aturbanov@openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/7905788e969727c81eea4397f0d9b918cdb5286a
Stats:     62 lines in 18 files changed: 0 ins; 13 del; 49 mod

8289126: Cleanup unnecessary null comparison before instanceof check in jdk.hotspot.agent

Reviewed-by: ayang, cjplummer

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

PR: https://git.openjdk.org/jdk/pull/9272
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic