Bug 259427

Summary: Allow aspect instance members to be used in if() poincuts
Product: [Tools] AspectJ Reporter: Ramnivas Laddad <ramnivas>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: DEVELOPMENT   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Ramnivas Laddad CLA 2008-12-19 20:35:54 EST
Currently, aspect instance variable can't be used directly inside an if() pointcut. For example, it is currently an error ("Cannot make a static reference to the non-static field") to do something like:

public aspect InstanceVariableIfCheck {
    private boolean enabled;

    before() : execution(* *(..)) && if(enabled) {
       ...
    }
}

That forces developers to do either:
before() : execution(* *(..)) && if(InstanceVariableIfCheck.aspectOf().enabled) {
   ...
}

or

before() : execution(* *(..)) {
   if(enabled) {
      ...
   }
}

The second style can be problematic for a newbie who may forget to call proceed() even when bypassing the advice logic.