On Wed, 29 Jun 2022 21:11:09 GMT, Andrey Turbanov <aturba...@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:
> 
>         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)

This pull request has now been integrated.

Changeset: df063f7d
Author:    Andrey Turbanov <aturba...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/df063f7db18a40ea7325fe608b3206a6dff812c1
Stats:     9 lines in 3 files changed: 0 ins; 4 del; 5 mod

8289484: Cleanup unnecessary null comparison before instanceof check in java.rmi

Reviewed-by: jpai, attila

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

PR: https://git.openjdk.org/jdk/pull/9332

Reply via email to