]> source.dussan.org Git - aspectj.git/commitdiff
257833: test and fix: anno atArgs and null
authoraclement <aclement>
Mon, 8 Dec 2008 19:35:40 +0000 (19:35 +0000)
committeraclement <aclement>
Mon, 8 Dec 2008 19:35:40 +0000 (19:35 +0000)
tests/bugs163/pr257833/NotNull.java [new file with mode: 0644]
tests/bugs163/pr257833/NotNullAspect.java [new file with mode: 0644]
tests/bugs163/pr257833/NotNullTest.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java
tests/src/org/aspectj/systemtest/ajc163/ajc163.xml

diff --git a/tests/bugs163/pr257833/NotNull.java b/tests/bugs163/pr257833/NotNull.java
new file mode 100644 (file)
index 0000000..47950d0
--- /dev/null
@@ -0,0 +1,3 @@
+package patterntesting.check.runtime;
+
+public @interface NotNull { }
diff --git a/tests/bugs163/pr257833/NotNullAspect.java b/tests/bugs163/pr257833/NotNullAspect.java
new file mode 100644 (file)
index 0000000..f5e8654
--- /dev/null
@@ -0,0 +1,15 @@
+package patterntesting.check.runtime;
+
+public aspect NotNullAspect {
+
+    pointcut ctorWithNotNullArg() :
+        execution(*..*.new(*)) && @args(NotNull);
+
+    before() : ctorWithNotNullArg() {
+        Object[] args = thisJoinPoint.getArgs();
+        if (args[0] == null) {
+            throw new AssertionError("@NotNull constraint violated");
+        }
+    }
+
+}
diff --git a/tests/bugs163/pr257833/NotNullTest.java b/tests/bugs163/pr257833/NotNullTest.java
new file mode 100644 (file)
index 0000000..f3e64c7
--- /dev/null
@@ -0,0 +1,21 @@
+package patterntesting.check.runtime;
+
+
+public class NotNullTest {
+    
+    private String s2;
+    private static final String nullString = null;
+    
+    public NotNullTest() {
+    }
+    
+    public NotNullTest(@NotNull String s) {
+        s2 = s;
+    }
+    
+    public static void main(String []argv) {
+        new NotNullTest("something");
+        new NotNullTest(nullString);
+    }
+
+}
index a403dffa3226d9eee68e135d622aad14a9925618..ec6d91012de99a40ac8164c1ff51f7525cc3f163 100644 (file)
@@ -28,6 +28,10 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
 
 public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testNonNullAtArgs_pr257833() {
+               runTest("param annos and at args");
+       }
+
        // public void testAtAspectJDecp_pr164016() {
        // runTest("ataspectj decp");
        // }
index eb1034a60352fb1867271d16f1a79179d76552de..9c65c6f953b8423ac3e2806f3fc505cdc14ef2e1 100644 (file)
         <message kind="warning" line="4" text="has not been applied"/>
       </compile>
     </ajc-test>
+
+    <ajc-test dir="bugs163/pr257833" title="param annos and at args">
+      <compile files="NotNull.java NotNullAspect.java NotNullTest.java" options="-1.5 -showWeaveInfo">
+        <message kind="weave" text="Join point 'constructor-execution(void patterntesting.check.runtime.NotNullTest.&lt;init&gt;(java.lang.String))' in Type"/>
+      </compile>
+      <run class="patterntesting.check.runtime.NotNullTest"/>
+    </ajc-test>
     
     <ajc-test dir="bugs163/pr253109" title="generic pointcuts - 2">
       <compile files="CodeTwo.java" options="-1.5"/>