The ClassUtils.getMostSpecificMethod() doesn't check any correlations between a targetClass and method.getDeclaringClass() causing unexpected behavior when a maybe method requested from fully different hierarchy.

See discussion here: https://github.com/spring-projects/spring-integration/pull/3082/files#r335614474

Comment From: snicoll

I believe this is the expected behavior.

The Javadoc for getMostSpecificMethod for the targetClass states:

the target class for the current invocation (may be null or may not even implement the method)

The method description also states:

Given a method, which may come from an interface, and a target class used in the current reflective invocation, find the corresponding target method if there is one