Community
Participate
Working Groups
The compiler silently accepts ---- public class DeclarePrecedence { public static void main(String[] args) { System.out.println("hello"); } } aspect DP { declare precedence: DeclarePrecedence, DP; before() : staticinitialization(DeclarePrecedence) { System.out.println("ok"); } } ---- Since this is likely to be a mistake, an error would be nice. However, that would mean saying (!TargetClass && TargetClass+) to pick out the aspect subtypes of TargetClass.
Created attachment 8210 [details] Patch for: weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java This will produce a compile time error message if a declare precedence statement includes a non-aspect type.
I'm a little worried that this change would prevent the use of marker interfaces for precendence, something like this: public aspect Priority { public interface Highest {} public interface Lowest {} declare precedence: Highest+, *, Lowest+; } aspect Security implements Priority.Highest {} I'd suggest modifying Andy's patch to check if pi.isIncludeSubtypes() and if so not to produce an error since it is possible for an aspect to match any such pattern. Otherwise, I'm assigning this to Andy to implement his patch and add both Wes's original positive test case and my negative test case to the test suite.
Fix checked in. I modified my patch to allow for non-aspect types where the subtypes are included. Both test cases are now in ajcTests.xml. Here is the error message that now comes out whilst compiling Wes' test. Wording is ok I hope? "Non-aspect types can only be specified in a declare precedence statement when subtypes are included. Non-aspect type is : DeclarePrecedenceTestClass"
updating target flag to indicate inclusion in 1.2 release.