]> source.dussan.org Git - aspectj.git/commitdiff
annotation removal - extra checks
authoraclement <aclement>
Sat, 27 Nov 2010 06:23:20 +0000 (06:23 +0000)
committeraclement <aclement>
Sat, 27 Nov 2010 06:23:20 +0000 (06:23 +0000)
tests/features1611/declareMinus/Unsupported.java [new file with mode: 0644]
tests/features1611/declareMinus/WithValues.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc1611/NewFeatures.java
tests/src/org/aspectj/systemtest/ajc1611/newfeatures-tests.xml

diff --git a/tests/features1611/declareMinus/Unsupported.java b/tests/features1611/declareMinus/Unsupported.java
new file mode 100644 (file)
index 0000000..4275b5a
--- /dev/null
@@ -0,0 +1,24 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Anno {
+       String foo();
+}
+
+@Anno(foo="anc")
+aspect X {
+
+       //declare @method: int i: -@Anno;
+       declare @method: int i(..): -@Anno;
+       declare @type: X: -@Anno;
+    declare @field: int i: -@Anno(foo="abc");  
+       
+       public static void main(String[] args) throws Exception {
+               if (X.class.getDeclaredField("i").getAnnotation(Anno.class)==null) {
+                       System.out.println("not there");
+               } else {
+                       System.out.println("failed");
+               }
+       }
+}
\ No newline at end of file
diff --git a/tests/features1611/declareMinus/WithValues.java b/tests/features1611/declareMinus/WithValues.java
new file mode 100644 (file)
index 0000000..a756c2e
--- /dev/null
@@ -0,0 +1,22 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Anno {
+       String foo();
+}
+
+public aspect WithValues {
+       @Anno(foo="anc")
+       int i;
+       
+       declare @field: int i: -@Anno;
+       
+       public static void main(String[] args) throws Exception {
+               if (WithValues.class.getDeclaredField("i").getAnnotation(Anno.class)==null) {
+                       System.out.println("not there");
+               } else {
+                       System.out.println("failed");
+               }
+       }
+}
\ No newline at end of file
index 5fd491f61ac68c9118915493fcc4f4d3f0e13c7e..3df8d1a00293e8c4aa9091ac50964ccd2b2a5e27 100644 (file)
@@ -54,6 +54,14 @@ public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase {
                runTest("declare minus - multifiles - 3");
        }
 
+       public void testDeclareMinusWithValues() {
+               runTest("declare minus - with values");
+       }
+
+       public void testDeclareMinusUnsupported() {
+               runTest("declare minus - unsupported");
+       }
+
        public void testBinaryWeaving() {
                runTest("binary weaving");
        }
index d8bae42fb613ac7acd9cf8231ad714b0f0c67fdc..ff56008a8a15ba6fdc9d553e10aa84c461a9ed38 100644 (file)
        </stdout></run>
   </ajc-test>
   
+  <ajc-test dir="features1611/declareMinus" title="declare minus - with values">
+    <compile files="WithValues.java" options="-1.5"/>
+    <run class="WithValues">
+    <stdout>
+    <line text="not there"/>
+    </stdout></run>
+  </ajc-test>
+  
+  <ajc-test dir="features1611/declareMinus" title="declare minus - unsupported">
+    <compile files="Unsupported.java" options="-1.5">
+        <message kind="error" line="13" text="Annotation removal only supported for declare @field (compiler limitation)"/>
+        <message kind="error" line="14" text="Annotation removal only supported for declare @field (compiler limitation)"/>
+        <message kind="error" line="15" text="Annotation removal does not allow values to be specified for the annotation (compiler limitation)"/>
+    </compile>
+  </ajc-test>
+  
   <ajc-test dir="features1611/declareMinus" title="binary weaving">
     <compile files="aspectjtest/AnnotationA.java aspectjtest/AnnotationB.java aspectjtest/MyEntity.java aspectjtest/HelloTest.java" outjar="code.jar" options="-1.5"/>
     <compile files="aspectjtest/ExampleItd.aj" inpath="code.jar" options="-1.5 -showWeaveInfo">