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 ------------- Commit messages: - [PATCH] Cleanup unnecessary null comparison before instanceof check in java.naming Changes: https://git.openjdk.java.net/jdk/pull/5374/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5374&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8273484 Stats: 41 lines in 12 files changed: 0 ins; 11 del; 30 mod Patch: https://git.openjdk.java.net/jdk/pull/5374.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5374/head:pull/5374 PR: https://git.openjdk.java.net/jdk/pull/5374