Example usage for org.springframework.aop.aspectj RuntimeTestWalker testsSubtypeSensitiveVars

List of usage examples for org.springframework.aop.aspectj RuntimeTestWalker testsSubtypeSensitiveVars

Introduction

In this page you can find the example usage for org.springframework.aop.aspectj RuntimeTestWalker testsSubtypeSensitiveVars.

Prototype

public boolean testsSubtypeSensitiveVars() 

Source Link

Document

If the test uses any of the this, target, at_this, at_target, and at_annotation vars, then it tests subtype sensitive vars.

Usage

From source file:org.springframework.aop.aspectj.AspectJExpressionPointcut.java

@Override
public boolean matches(Method method, @Nullable Class<?> targetClass, boolean beanHasIntroductions) {
    obtainPointcutExpression();/*from w w  w  .  j a  v  a  2 s .c  o m*/
    Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
    ShadowMatch shadowMatch = getShadowMatch(targetMethod, method);

    // Special handling for this, target, @this, @target, @annotation
    // in Spring - we can optimize since we know we have exactly this class,
    // and there will never be matching subclass at runtime.
    if (shadowMatch.alwaysMatches()) {
        return true;
    } else if (shadowMatch.neverMatches()) {
        return false;
    } else {
        // the maybe case
        if (beanHasIntroductions) {
            return true;
        }
        // A match test returned maybe - if there are any subtype sensitive variables
        // involved in the test (this, target, at_this, at_target, at_annotation) then
        // we say this is not a match as in Spring there will never be a different
        // runtime subtype.
        RuntimeTestWalker walker = getRuntimeTestWalker(shadowMatch);
        return (!walker.testsSubtypeSensitiveVars()
                || (targetClass != null && walker.testTargetInstanceOfResidue(targetClass)));
    }
}