Community
Participate
Working Groups
When defining a generic aspect with a paramterized PC, using that PC in an advice declaration causes an 'incompatible type' error. Example: public abstract aspect GenericAspect<Par1> { abstract pointcut checkpoint(Par1 par1); // advice declaration causes error after(Par1 par1): checkpoint(par1) {// do something} } Using 1.3.0.20051220093604 and AspectJ 1.5.0, the compiler complains: "incompatible type, expected java.lang.Object found BindingTypePattern(TPar1;, 0). Check the type specified in your pointcut" Since it is possible to paramterize a named PC in subaspects: public abstract aspect GenericAspect<Par1> { abstract pointcut checkpoint(Par1 par1); } public aspect SubAspect1 extends GenericAspect<Main>{ pointcut checkpoint(Main main): call(void Main.test()) && target(main); after (Main main): checkpoint(main) { System.out.println("Caught by 1."); } } public aspect SubAspect2 extends GenericAspect<Main2>{ pointcut checkpoint(Main2 main): call(void Main2.test()) && target(main); after (Main2 main): checkpoint(main) { System.out.println("Caught by 2."); } } ... and since it is possible to use generic PC utilizing unnamed PCs in a generic aspect: public abstract aspect GenericAspect<Par1> { // works after(Par1 par1): call(void Par1.test()) && target(par1) {// something } } ... it seems that this is a bug.
Passing over to compiler
This was broken in 1.5.0 but is fixed in HEAD (I assume by Adrian or Andy.) I'm going to close it as such, at the risk of missing an issue they've found but which is not covered by the test case below, which fails in 1.5.0, passes now, and is checked in as tests/bugs151/pr123553: --------------------------------------------------- public class A { static Object s; public static void main(String[] args) { String t = "Hello, World!"; t.toString(); if (s != t) throw new Error(); } static abstract aspect GenericAspect<T> { abstract pointcut checkpoint(T t); // advice declaration causes error after(T t): checkpoint(t) { s = t;} } static aspect AAA extends GenericAspect<String>{ pointcut checkpoint(String s) : target(s) && call(String String.toString()); } }