eclipse-aspectj / aspectj

Other
303 stars 86 forks source link

address annotation style if() pointcut binding restrictions that don't affect code style #120

Closed aclement closed 2 years ago

aclement commented 2 years ago

annotation style binding is not great when if() pointcuts are involved. There is a compiler limitation that requires reference pointcuts to always bind variables that are used in if() pointcut support methods. This does not work:

@Aspect class Azpect {
  @Pointcut("this(f) && if()") public static boolean method(Foo f) { return f.isTrue();}
  @Before("method(*) && execution(* *.run(..))") public void beforeAdvice() {}
}

You are forced to bind o in the method beforeAdvice() - code style does not have this restriction. Compiling the above will give something like:

Missing binding for if() pointcut method (method).  Parameter 1 (D d) must be bound - even in reference pointcuts  (compiler limitation)