RFR: 8289126: Cleanup unnecessary null comparison before instanceof check in jdk.hotspot.agent
Andrey Turbanov
aturbanov at openjdk.org
Fri Jun 24 09:27:22 UTC 2022
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)
-------------
Commit messages:
- 8289126: Cleanup unnecessary null comparison before instanceof check in jdk.hotspot.agent
Changes: https://git.openjdk.org/jdk/pull/9272/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=9272&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8289126
Stats: 62 lines in 18 files changed: 0 ins; 13 del; 49 mod
Patch: https://git.openjdk.org/jdk/pull/9272.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/9272/head:pull/9272
PR: https://git.openjdk.org/jdk/pull/9272
More information about the serviceability-dev
mailing list