-
Enhancement
-
Resolution: Fixed
-
P5
-
None
-
b04
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);
}
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);
}