Skip to content

Commit

Permalink
MethodParameter.equals properly checks overridden containing class
Browse files Browse the repository at this point in the history
Closes gh-23352
  • Loading branch information
jhoeller committed Aug 1, 2019
1 parent b5adf8d commit 75a8050
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class MethodParameter {
@Nullable
Map<Integer, Integer> typeIndexesPerLevel;

/** The containing class. Could also be supplied by overriding {@link #getContainingClass()} */
@Nullable
private volatile Class<?> containingClass;

Expand Down Expand Up @@ -378,6 +379,12 @@ void setContainingClass(Class<?> containingClass) {
this.containingClass = containingClass;
}

/**
* Return the containing class for this method parameter.
* @return a specific containing class (potentially a subclass of the
* declaring class), or otherwise simply the declaring class itself
* @see #getDeclaringClass()
*/
public Class<?> getContainingClass() {
Class<?> containingClass = this.containingClass;
return (containingClass != null ? containingClass : getDeclaringClass());
Expand Down Expand Up @@ -652,7 +659,7 @@ public boolean equals(Object other) {
return false;
}
MethodParameter otherParam = (MethodParameter) other;
return (this.containingClass == otherParam.containingClass &&
return (getContainingClass() == otherParam.getContainingClass() &&
ObjectUtils.nullSafeEquals(this.typeIndexesPerLevel, otherParam.typeIndexesPerLevel) &&
this.nestingLevel == otherParam.nestingLevel &&
this.parameterIndex == otherParam.parameterIndex &&
Expand Down

0 comments on commit 75a8050

Please sign in to comment.