我是 AspectJ 的新手,仍在学习如何编写代码。我正在尝试为 nextYear() 方法创建切入点和建议,但我不断收到“警告:(39, 0) ajc:ChristkindAspect 中定义的建议尚未应用 [Xlint:adviceDidNotMatch]”。我知道这可能是因为没有直接创建对象,并且我不能使用 target(christkind enter code here),但我找不到解决方案。有人可以帮忙吗?先感谢您!
pointcut nextYear(Christkind christkind, Population population):
call(* *Christkind.nextYear(Population))&& args(population) &&
target(christkind);
before(Christkind christkind,Population population): nextYear(christkind,population) {
System.out.println("New Year");
populationSize(population);
numbOfWIshes(population);
//wishStrength(population); }
Run Code Online (Sandbox Code Playgroud)
在主要方法中,我有:
Christkind.nextYear(population);
Run Code Online (Sandbox Code Playgroud)