Skip to content

Commit

Permalink
Handle base=derived case in Util#isOverridden (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Oct 27, 2024
1 parent 486510e commit 9b35401
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/java/org/kohsuke/stapler/ReflectionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public static Annotation[] union(Annotation[] a, Annotation[] b) {
*/
public static boolean isOverridden(
@NonNull Class<?> base, @NonNull Class<?> derived, @NonNull String methodName, @NonNull Class<?>... types) {
if (base == derived) {
// If base and derived are the same type, the method is not overridden by definition
return false;
}
// If derived is not a subclass or implementor of base, it can't override any method
// Technically this should also be triggered when base == derived, because it can't override its own method, but
// the unit tests explicitly test for that as working.
Expand Down

0 comments on commit 9b35401

Please sign in to comment.