I'm having some trouble getting my aspects to work correctly. For some reason they seem to only be working when I am really generic about where the aspect is applied. Out of the four pointcut/advice only the last matches and outputs anything. What am I missing here?
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 class:
public class Game {
public void addPlayer(Player player) {
System.out.println("inside class");
this.players.add(player);
}
}
Output:
inside class
*(..):player has been added