Pallab Roy Chowdhury
Pallab Roy Chowdhury

Reputation: 13

Pointcut that will capture constructor calls

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?

Upvotes: 1

Views: 3162

Answers (1)

kriegaex
kriegaex

Reputation: 67317

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".

Upvotes: 1

Related Questions