这个
targetClass
在中指定
MethodMatcher.matches(Method method, Class<?> targetClass)
不用于检查目标调用类的合格性
.
它用于
寻找最具体的目标方法
适用于给定方法(指定为参数)的目标类。它还解决了以下问题:
Java bridge methods
.
这是一个样本
matches
方法来自
org.springframework.aop.aspectj.AspectJExpressionPointcut
班
public boolean matches(Method method, Class<?> targetClass, boolean beanHasIntroductions) {
this.checkReadyToMatch();
Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
ShadowMatch shadowMatch = this.getShadowMatch(targetMethod, method);
...
}
这是来自
org.springframework.aop.support.AopUtils#getMostSpecificMethod
给定一个方法(可能来自接口)和使用的目标类
在当前的AOP调用中,如果有对应的目标方法,请找到相应的目标方法。E、 g.该方法可以是
IFoo.bar()
目标类可能是
DefaultFoo
DefaultFoo.bar()
. 这样可以找到该方法上的属性。
注:
与…对比
org.springframework.util.ClassUtils#getMostSpecificMethod
,该方法解析Java 5桥接方法,以便从
起初的
方法定义。