-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P5
-
Affects Version/s: 16, 17
-
Component/s: core-libs
-
None
-
b15
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);
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);