Search code examples
javaaspectjaop

How can I exclude getters and setters in aspectJ?


I have a class aspectJ in my maven project whitch hepls me to show the Begin and the End of any called method in my project. I try now to exclude all getters and setters. I try modify this annotation: @Around("execution(public * *(..)) by @Around("execution(public * *(..) && !within(* set*(..))")

But it doesn't whork and it gives me that in the consol:

 [ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.7:compile (default) on project spb-lceb: AJC compiler errors:
 [ERROR] error at @Around("execution(public * *(..) && !within(* set*(..))")
 Syntax error on token "execution(public * *(..) && !within(* set*(..))", ")" expected

Any idea


Solution

  • I think it's only a typo because you have a mising ) at the end of the execution call before the && operator:

    @Around("execution(public * *(..) && !within(* set*(..))")
    

    Should be:

    @Around("execution(public * *(..)) && !within(* set*(..))")
    

    Try it, that should do the trick.

    And for the methods that begins with Get the best solution is to rename them to get rid of this conflict.