Pointcut that will capture constructor calls

2019-08-13 07:50发布

问题:

I am trying to define a pointcut which will capture all the constructor calls, regardless of the modifier, return type, or class. I have used the following code

after():execution(* * * .new(..))

I am having an error :

Syntax error on token "*", "(" expected.

Can anybody suggest what may be the right approach?

回答1:

Just remove the middle star "*". It does not make sense to specify a return type for a constructor call because it is clear that the constructor will always return an instance of the class it is defined for.

after() : execution(* *.new(..))

BTW, you should also remove the whitespace before ".new".



标签: aspectj