On Mon, 6 Sep 2021 08:08:33 GMT, Andrey Turbanov <github.com+741251+turban...@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 Good catch! Improved. Not sure why IDEA don't report such case. Created https://youtrack.jetbrains.com/issue/IDEA-277851 ------------- PR: https://git.openjdk.java.net/jdk/pull/5374