Integrated: 8273484: Cleanup unnecessary null comparison before instanceof check in java.naming

Andrey Turbanov github.com+741251+turbanoff at openjdk.java.net
Sun Sep 12 13:52:52 UTC 2021


On Mon, 6 Sep 2021 08:08:33 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:

> Update code checks both non-null and instance of a class in java.naming module classes.
> The checks and explicit casts could also be replaced with pattern matching for the instanceof operator.
> For example:
>     The following code:
> 
>         return (obj != null &&
>                 obj instanceof CompoundName &&
>                 impl.equals(((CompoundName)obj).impl));
> 
> 
> Can be simplified to:
>     
> 
>         return (obj instanceof CompoundName other) &&
>                 impl.equals(other.impl);
> 
> 
> See similar cleanup in java.base - https://bugs.openjdk.java.net/browse/JDK-8258422

This pull request has now been integrated.

Changeset: 2ee1f96c
Author:    Andrey Turbanov <turbanoff at gmail.com>
Committer: Aleksei Efimov <aefimov at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/2ee1f96c14b80b63a29445629b1f2e1caf88e075
Stats:     44 lines in 13 files changed: 0 ins; 11 del; 33 mod

8273484: Cleanup unnecessary null comparison before instanceof check in java.naming

Reviewed-by: aefimov, dfuchs

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

PR: https://git.openjdk.java.net/jdk/pull/5374


More information about the core-libs-dev mailing list