I was half surprised you didn't get a compiler warning/error that it didn't like your alternatives for binding - to be clear, there is nothing wrong with them theoretically, but I thought the compiler would say it doesn't support doing that. But I just crafted a small similar program and it does what you describe. So definitely an issue - it should either work or you get told it isn't supported. But it shouldn't silently do the wrong thing. My test program:
public class Code {
public static void main(String []argv) {
foo("fooname",1,2,3);
bar("barone","bartwo","barname",1,2,3);
}
public static void foo(String username, int i, int j, int k) {}
public static void bar(String a, String b, String username, int i, int j, int k) { }
}
aspect X {
before(String username): (execution(public static * foo(..)) && args(username,..)) ||
(execution(public static * bar(..)) && args(*,*,username,..)) {
System.out.println("username = "+username);
}
}
---
prints
username = fooname
username = barone
I'm suspecting the pointcut validation and rewriting that goes on. I'm sure you know what the workaround is. Just have two pieces of advice with different pointcuts attached.
Andy