-
Enhancement
-
Resolution: Fixed
-
P5
-
None
-
b05
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:
if ((obj != null) && (obj instanceof TCPEndpoint)) {
TCPEndpoint ep = (TCPEndpoint) obj;
if (port != ep.port || !host.equals(ep.host))
Can be simplified to:
if (obj instanceof TCPEndpoint ep) {
if (port != ep.port || !host.equals(ep.host))
The checks and explicit casts could also be replaced with pattern matching for the instanceof operator.
For example:
The following code:
if ((obj != null) && (obj instanceof TCPEndpoint)) {
TCPEndpoint ep = (TCPEndpoint) obj;
if (port != ep.port || !host.equals(ep.host))
Can be simplified to:
if (obj instanceof TCPEndpoint ep) {
if (port != ep.port || !host.equals(ep.host))