]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bugzilla Bug 53012
authoraclement <aclement>
Fri, 19 Mar 2004 09:28:14 +0000 (09:28 +0000)
committeraclement <aclement>
Fri, 19 Mar 2004 09:28:14 +0000 (09:28 +0000)
   declare precedence on a class should be a compile-time error

tests/ajcTests.xml
tests/bugs/declarePrecedenceWithClasses/DeclarePrecedenceTestClass.java [new file with mode: 0644]
tests/bugs/declarePrecedenceWithClasses/Priority.aj [new file with mode: 0644]
weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java

index 33c0c645af21510565d64f8f0427ae36875ec7a7..ce4620ece5ac93f1ba815059defd9ca149753d3b 100644 (file)
                </compile>
        </ajc-test>
        
+    <ajc-test dir="bugs/declarePrecedenceWithClasses" pr="53012"
+        title="declare precedence on a class should be a compile-time error">
+        <compile files="DeclarePrecedenceTestClass.java" >
+          <message kind="error" line="10" text="Non-aspect types can only be specified"/>
+        </compile>
+    </ajc-test>
+    
+    <ajc-test dir="bugs/declarePrecedenceWithClasses" pr="53012"
+        title="declare precedence on a class should be a compile-time error">
+        <compile files="Priority.aj" />
+    </ajc-test>
+       
 </suite>
diff --git a/tests/bugs/declarePrecedenceWithClasses/DeclarePrecedenceTestClass.java b/tests/bugs/declarePrecedenceWithClasses/DeclarePrecedenceTestClass.java
new file mode 100644 (file)
index 0000000..98e2779
--- /dev/null
@@ -0,0 +1,15 @@
+//Bug 53012
+// DP contains a declare precedence statement that mentions classes
+
+public class DeclarePrecedenceTestClass {
+       public static void main(String[] args) {
+               System.out.println("hello");
+       }
+}
+aspect DP {
+       declare precedence: DeclarePrecedenceTestClass, DP;
+       
+       before() : staticinitialization(DeclarePrecedenceTestClass) {
+               System.out.println("ok"); 
+       }
+}
diff --git a/tests/bugs/declarePrecedenceWithClasses/Priority.aj b/tests/bugs/declarePrecedenceWithClasses/Priority.aj
new file mode 100644 (file)
index 0000000..fc44fbf
--- /dev/null
@@ -0,0 +1,11 @@
+// Bug 53012\r
+// Although the declare precedence mentions interfaces (and not aspects explicitly), it does\r
+// mention with a '+' suffix - this should be allowed.\r
+\r
+public aspect Priority {\r
+       public interface Highest {}\r
+       public interface Lowest {}\r
+       declare precedence: Highest+, *, Lowest+;\r
+}\r
+\r
+aspect Security implements Priority.Highest {}\r
index 4106abbc4e858b344af390073b0fde157688428c..d7e19035714c6651a2e7a9beda7bee1e4d59db27 100644 (file)
@@ -82,6 +82,14 @@ public class DeclarePrecedence extends Declare {
                }
                ResolvedTypeX exactType = pi.getExactType().resolve(scope.getWorld());
                if (exactType == ResolvedTypeX.MISSING) continue;
+               
+               // Cannot do a dec prec specifying a non-aspect types unless suffixed with a '+'
+               if (!exactType.isAspect() && !pi.isIncludeSubtypes()) {
+                       scope.getWorld().showMessage(IMessage.ERROR,
+                               "Non-aspect types can only be specified in a declare precedence statement when subtypes are included.  Non-aspect type is : "+exactType.getName(),
+                               pi.getSourceLocation(),null);
+               }
+               
                for (int j=0; j < patterns.size(); j++) {
                        if (j == i) continue;
                        TypePattern pj = patterns.get(j);