将捕获构造函数调用的切入点 [英] 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(..))
我遇到错误:
令牌"*",("应为语法错误.
Syntax error on token "*", "(" expected.
有人能建议什么是正确的方法吗?
Can anybody suggest what may be the right approach?
推荐答案
只需删除中间星号"*".为构造函数调用指定返回类型没有意义,因为很明显构造函数将始终返回为其定义的类的实例.
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(..))
顺便说一句,您还应该删除".new"之前的空格.
BTW, you should also remove the whitespace before ".new".
这篇关于将捕获构造函数调用的切入点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!