]> source.dussan.org Git - aspectj.git/commitdiff
tests for pr107953 and newsgroup reported issue of varargs matching with type variabl...
authoracolyer <acolyer>
Tue, 30 Aug 2005 17:07:09 +0000 (17:07 +0000)
committeracolyer <acolyer>
Tue, 30 Aug 2005 17:07:09 +0000 (17:07 +0000)
tests/bugs150/ParameterizedVarArgMatch.aj [new file with mode: 0644]
tests/bugs150/pr107953.java [new file with mode: 0644]
tests/java5/ataspectj/ataspectj/misuse/Test019.java
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
tests/src/org/aspectj/systemtest/ajc150/ataspectj/misuse.xml

diff --git a/tests/bugs150/ParameterizedVarArgMatch.aj b/tests/bugs150/ParameterizedVarArgMatch.aj
new file mode 100644 (file)
index 0000000..5f0bf3f
--- /dev/null
@@ -0,0 +1,17 @@
+class Test1<E> {
+    public void method1(E...args) {
+    }
+}
+
+public aspect ParameterizedVarArgMatch {
+       
+       public static void main(String[] args) {
+               new Test1<String>().method1("a","b","c");
+       }
+       
+       
+    after(Test1 test1, Object[] arg) returning: 
+       execution(* Test1.method1(Object...)) && target(test1) && args(arg) {
+        System.out.println("got here");
+    }
+}
\ No newline at end of file
diff --git a/tests/bugs150/pr107953.java b/tests/bugs150/pr107953.java
new file mode 100644 (file)
index 0000000..8e42817
--- /dev/null
@@ -0,0 +1,18 @@
+import java.lang.annotation.*;
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class pr107953 {
+       
+       @AfterThrowing(pointcut="execution(* Foo.*(..))",throwing="RuntimeException")
+       public void missingBindingOfThrowingFormal() {
+               System.out.println("failure");
+       }
+               
+}
+
+class Foo {
+       void bar() {
+               throw new RuntimeException();
+       }
+}
\ No newline at end of file
index 301c3de35f49f425fadf02c545eb91ff67058a77..39f5167302056203e699c38a671228d42596be96 100644 (file)
@@ -6,6 +6,6 @@ import org.aspectj.lang.annotation.*;
 @Aspect
 public class Test019 {
   @AfterReturning(value="call(* *..*(..))",returning="f")
-  public void itsAFoo(Object f, int x) {
+  public void itsAFoo(int x, Object f) {
   }        
 }
index aba91b617a0bb111a055f9ef0bac424bff70c1ce..5d1ff7d8cad409c4a6038d8114528948f2922272 100644 (file)
@@ -298,6 +298,14 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          runTest("inner types and type variables");
   }
   
+  public void testAtAfterThrowingWithNoFormal() {
+         runTest("@AfterThrowing with no formal specified");
+  }
+  
+  public void testParameterizedVarArgsMatch() {
+         runTest("varargs with type variable");
+  }
+  
   // helper methods.....
   
   public SyntheticRepository createRepos(File cpentry) {
index ca204a231d8588d9bc0892c0f5b6946e9a23987b..a75e46b07a0be3697f986079300928dd9a87571b 100644 (file)
         </compile>
     </ajc-test>
  
+     <ajc-test dir="bugs150"  title="varargs with type variable">
+        <compile files="ParameterizedVarArgMatch.aj" options="-1.5">
+        </compile>
+    </ajc-test>
     <ajc-test dir="bugs150" pr="108104" title="multiple anonymous inner classes 2">
         <compile files="pr108104.aj" options="-1.5">
         </compile>
         <compile files="ShapeCommandMap.java" options="-1.5">
         </compile>
     </ajc-test>
-           
+
+    <ajc-test dir="bugs150/" pr="107953" title="@AfterThrowing with no formal specified">
+        <compile files="pr107953.java" options="-1.5">
+            <message kind="error" line="8" text="throwing formal 'RuntimeException' must be declared as the last parameter in the advice signature"></message>
+        </compile>
+    </ajc-test>
+               
     <ajc-test dir="bugs150/pr106130" pr="106130" title="test weaving with > 256 locals">
         <compile files="AroundLotsOfVars.java LotsOfVars.java" options="-preserveAllLocals"/>
         <run class="LotsOfVars">
index d0204141a0c3c02eeaa104f2e04766387962fcbc..9aec9d7a47e325e2089a5625060177cdbe392507 100644 (file)
     </ajc-test>
 
     <comment>very dirty hack - can't get this location to work properly so added match all error..</comment>
+    <comment>amc - with new checks for binding of returning this was giving a different message, so I 
+             tweaked the test slightly by swapping the order of the args</comment>
     <ajc-test dir="java5/ataspectj"
         pr="" title="@AfterReturning with wrong number of args">
         <compile files="ataspectj/misuse/Test019.java" options="-1.5 -Xdev:NoAtAspectJProcessing -Xlint:ignore">
             <message kind="error" line="1" text="the parameter x is not bound"/>
-            <message kind="error"/>
+            <message kind="error" line="1" text="formal unbound in pointcut"/>
         </compile>
     </ajc-test>