On 06.01.2014 15:26, Alexander Kriegisch wrote:
You can neither match "return null" nor assignments to local variables, only 
assignments to member variables.

What you can do is match returning calls or executions and check their results 
dynamically like this:

     after() returning(Object result) : execution(!void *(..)) {
         if (result == null)
             System.err.println(thisJoinPoint.toString() + " must not return 
null");
     }

As you can see, I am only matching non-void methods because void methods always 
implicitly return null. You can further refine the pointcut if you want to 
restrict it to being applied to certain packages or classes or if you want to 
match boolean methods returning false, int methods returning 0 etc.
I'm aware of that, but I am looking for a way to do check statically in a policy enforcement aspect (at compile time).
Detecting programming errors at runtime is not as reliable.
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to