On Wed, 29 Jun 2022 21:11:09 GMT, Andrey Turbanov <[email protected]> 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:
>
> 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))
>
>
> See similar cleanup in java.base -
> [JDK-8258422](https://bugs.openjdk.java.net/browse/JDK-8258422)
Looks good to me.
-------------
Marked as reviewed by jpai (Reviewer).
PR: https://git.openjdk.org/jdk/pull/9332