Community
Participate
Working Groups
Created attachment 235865 [details] eclipse AspectJ testcase An aspect is introducing a field and a method. Introducing an annotation onto the introduced field works fine; introducing an annotation onto the introduced **method** fails with the message "The method '...' does not exist" (where '...' is the method pattern). Aspect follows trait pattern: public interface Behavior { String hello(); } ===== @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface Behaved {} ===== public aspect Trait { public interface I extends Behavior {} declare parents: @Behaved * implements I; private String I.name = getClass().getName(); public String I.hello() { return "hello" + name; } } ===== @Behaved public class Target { public static aspect A { declare @field: * Target.name: @Tagged; // WORKY declare @method: * Target.hello(..): @Tagged; // NO WORKY } } ===== @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR }) @Retention(RetentionPolicy.RUNTIME) public @interface Tagged {} Test eclipse AspectJ project attached.
This comes down to a FIXME in the code (BcelClassWeaver): weaveInAddedMethods(); // FIXME asc are these potentially affected by declare annotation? The added methods are those like the one here, the method added to the top most implementor of an interface when the ITD method was on an interface. The fix is not trivial. These added methods are not of the right type to pass to the matching code for the declare annotation patterns.
Andy, I'm not sure what your comment means. Are you saying that it's not really fixable?
fixed. Not the cleanest impl but it works.
Andy, can you trigger a snapshot build? http://repo.spring.io/snapshot/org/aspectj/aspectjrt/1.8.0.BUILD-SNAPSHOT/ looks out of date and I'm having trouble building locally.
Testing against 1.7.4.BUILD-SNAPSHOT worked jim-dandy. AJDT 1.8.0(.latest) complains, and understandably, since it uses aspectj from the 1.8 branch, which didn't receive this fix, as it went into master, which is where 1.7.4 is coming from.