]> source.dussan.org Git - aspectj.git/commitdiff
265695: inherited anno matching
authoraclement <aclement>
Fri, 20 Feb 2009 20:57:15 +0000 (20:57 +0000)
committeraclement <aclement>
Fri, 20 Feb 2009 20:57:15 +0000 (20:57 +0000)
tests/bugs164/pr265695/Asp.aj [new file with mode: 0644]
tests/bugs164/pr265695/AspNew.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java
tests/src/org/aspectj/systemtest/ajc164/ajc164.xml

diff --git a/tests/bugs164/pr265695/Asp.aj b/tests/bugs164/pr265695/Asp.aj
new file mode 100644 (file)
index 0000000..296cb1f
--- /dev/null
@@ -0,0 +1,35 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Secured {
+       String value();
+}
+
+interface DemoService {
+    @Secured("READ")
+    void secureMethod();
+}
+
+
+class DemoServiceImpl implements DemoService {
+    public void secureMethod() {    }    
+}
+
+aspect X {
+       // None of these match, the subject at execution(secureMethod()) does not have the annotation
+       // see http://www.eclipse.org/aspectj/doc/next/adk15notebook/join-point-modifiers.html
+       before(): execution(@Secured * *Service+.*(..))  {      }
+       
+       before(): execution(@Secured * *Service.*(..))  {       }
+
+       before(): execution(@Secured * DemoService.*(..))  {    }
+       
+}
+
+public class Asp {
+       public static void main(String[] args) {
+               new DemoServiceImpl().secureMethod();
+       }
+}
+
diff --git a/tests/bugs164/pr265695/AspNew.aj b/tests/bugs164/pr265695/AspNew.aj
new file mode 100644 (file)
index 0000000..ae99590
--- /dev/null
@@ -0,0 +1,32 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Secured {
+       String value();
+}
+
+interface DemoService {
+    @Secured("READ")
+    void secureMethod();
+}
+
+
+class DemoServiceImpl implements DemoService {
+    public void secureMethod() {    }    
+}
+
+aspect X {
+       // None of these match, the subject at execution(secureMethod()) does not have the annotation
+       // see http://www.eclipse.org/aspectj/doc/next/adk15notebook/join-point-modifiers.html
+       before(): execution(@Secured! * *Service+.*(..))  {     }
+       
+       
+}
+
+public class AspNew {
+       public static void main(String[] args) {
+               new DemoServiceImpl().secureMethod();
+       }
+}
+
index 2351c665f31f451a3562cd0a0461ef24a1865132..6de409bdd0b3b26fbcebe8b3d2fa9bbceec9ab69 100644 (file)
@@ -32,6 +32,14 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
 
 public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testAnnoInherited_pr265695() {
+               runTest("anno inherited");
+       }
+
+       // public void testAnnoInherited_pr265695_2() {
+       // runTest("new syntax for inherited anno - 1");
+       // }
+
        public void testParserProblemSubArrayPatterns_pr148508() {
                runTest("parser problem for array subtypes");
        }
@@ -43,7 +51,7 @@ public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
        public void testIncorrectDateResolution_pr265360() {
                runTest("incorrect resolution of Date");
        }
-       
+
        public void testDualPreClinit_pr233032() {
                runTest("dual preClinit");
        }
@@ -144,11 +152,9 @@ public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
        }
 
        /**
-        * This test checks that local variable table for the interMethodDispatcher
-        * is built correctly, for the related code see
-        * IntertypeMethodDeclaration.generateDispatchMethod(). It checks non-static
-        * and static ITDs. Once the information here is correct then around advice
-        * on ITDs can also be correct.
+        * This test checks that local variable table for the interMethodDispatcher is built correctly, for the related code see
+        * IntertypeMethodDeclaration.generateDispatchMethod(). It checks non-static and static ITDs. Once the information here is
+        * correct then around advice on ITDs can also be correct.
         */
        public void testBrokenLVT_pr194314_3() throws Exception {
                runTest("broken lvt - 3");
index 9dbe2547943ef3367015f1fce36ad9ba19cabe16..11acc297908387958257a499b5d87a3a3799c682 100644 (file)
@@ -1,6 +1,20 @@
 <!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
 
 <suite>
+
+   <ajc-test dir="bugs164/pr265695" title="anno inherited">
+     <compile files="Asp.aj" options="-showWeaveInfo -1.5">
+       <message kind="warning" line="22" text="advice defined"/>
+       <message kind="warning" line="24" text="advice defined"/>
+       <message kind="warning" line="26" text="advice defined"/>
+     </compile>
+   </ajc-test>
+   
+   <ajc-test dir="bugs164/pr265695" title="new syntax for inherited anno - 1">
+     <compile files="AspNew.aj" options="-1.5 -showWeaveInfo">
+       <message kind="weave" line="22" text="foo"/>
+     </compile>
+   </ajc-test>
     
     <ajc-test dir="bugs164/pr265418" title="varargs">
       <compile files="A.java" options="-1.5"/>
@@ -21,7 +35,6 @@
      <run class="PR148508">
      </run>
    </ajc-test>
-   
     
     <ajc-test dir="bugs164/pr265360" title="incorrect resolution of Date">
       <compile files="Foo.java Main.java" options="-1.5">