我在让我的方面正常工作时遇到了一些麻烦。出于某种原因,它们似乎仅在我对应用方面的位置非常通用时才起作用。在四个切入点/建议中,只有最后一个匹配并输出任何内容。我在这里想念什么?
public aspect VerboseAspect
{
after(Game game) returning:
call(* Game.addPlayer(Player))
&& target(game) {
System.out.println("addPlayer(Player): player has been added");
}
after(Game game) returning:
call(* Game.addPlayer(..))
&& target(game) {
System.out.println("addPlayer(..): player has been added");
}
after(Game game) returning:
call(* Game.*(Player))
&& target(game) {
System.out.println("*(Player):player has been added");
}
after(Game game) returning:
call(* Game.*(..))
&& target(game) {
System.out.println("*(..):player has been added");
}
}
Java类:
public class Game {
public void addPlayer(Player player) {
System.out.println("inside class");
this.players.add(player);
}
}
输出:
inside class
*(..):player has been added