Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] [WARNING] can not build thisJoinPoint lazily for this advice since it has no suitable guard

Hi Andy!

I managed to solve the test compilation problem for my  aspect using stackoverflow 😊

Now when I compile I see the following warning:

 [WARNING] can not build thisJoinPoint lazily for this advice since it has no suitable guard [Xlint:noGuardForLazyTjp]
/repo/eraonel/git/java-runtime-stats/target/classes!com/ericsson/commonlibrary/javaruntimestats/aspects/DeprecatedMethodsAspect.class:34

 

What do I need to do to get rid of the warning?


br,


//mikael


This is my aspect:


public aspect DeprecatedMethodsAspect  {
       
    private  DeprecatedMethods deprecatedMethods = new DeprecatedMethodsImpl();

    //Pointcuts to match joinpoint.
    pointcut deprecated() :
        @annotation(Deprecated) && (call(public * *(..)) || call(*.new(..)));

    pointcut beta() :
        @annotation(com.google.common.annotations.Beta);

    pointcut deprecatedMethods() :
        deprecated() && !beta();
         

    before() : deprecatedMethods() {  //This is the line that compiler warns for.
        deprecatedMethods.collect(thisJoinPoint);
    }

    @VisibleForTesting
    public void setDeprecatedMethods(DeprecatedMethods deprecatedMethods) {
        this.deprecatedMethods = deprecatedMethods;
    }
   
   

}

Back to the top