Jan 17
Adrian has been talking about getting Java 5 support into AspectJ. I can imagine how much work that has been, and I am impressed to hear that AspectJ 5 now supports full source compilation of Java 5 programs.
AJDT also has integrated in to Eclipse 3.1 M4 with full Java 5 support, eager parsing, and early error indications all working happily (not officially released).
Check out a SimpleAspect. Java 5 style:
import java.util.List; @MyAnnotation public aspect SimpleAspect { int x; static ListmyStringList; public static void main(String[] args) { for(String s:args) { System.out.println(s); myStringList.add(s); } C c = new C(); c.whatCsDoBest(); c.somethingElse(); c.myInt(5); c.somethingElse(new Object(), new Object()); c.whoAmI(); D d = new D(); d.whoAmI(); } pointcut annotatedExecution() : execution(@MyAnnotation * *(..)); before() : annotatedExecution() { System.out.println(thisJoinPoint + " has an annotation."); } before() : call(* myInt(..)) && args(int) { System.out.println("Autoboxing match"); } before(Object[] objects) : call(* somethingElse(Object...)) && args(objects) { System.out.print("Varargs match: "); for (Object o:objects) { System.out.print(o + " "); } System.out.println(); } before() : execution(C whoAmI()) { System.out.println("Covariant match on execution(C whoAmI())"); } before() : execution(D whoAmI()) { System.out.println("Covariant match on execution(D whoAmI())"); } } class C { @MyAnnotation public void whatCsDoBest() { } public void somethingElse(Object... objects) { } public C whoAmI() { return this; } Progress getAspectJ5Progress() { return Progress.EXCELLENT; } public int myInt(Integer i) { return i; } } class D extends C { public D whoAmI() { return this; } } @interface MyAnnotation {} enum Progress { OK, GOOD, VERYGOOD, EXCELLENT }