]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for Bugzilla Bug 42539
authorjhugunin <jhugunin>
Thu, 4 Sep 2003 15:49:08 +0000 (15:49 +0000)
committerjhugunin <jhugunin>
Thu, 4 Sep 2003 15:49:08 +0000 (15:49 +0000)
   throw derivative pointcuts not advised

tests/ajcTests.xml
tests/bugs/throwsSignature/ExceptionAspect.java [new file with mode: 0644]
tests/bugs/throwsSignature/ExceptionBugTest.java [new file with mode: 0644]
weaver/src/org/aspectj/weaver/patterns/ThrowsPattern.java

index db51bfc2c667523bf664092aa5035fb389d316f7..6f9e4dddfe35219d98970c24ee056d6fbeff3231 100644 (file)
                                aspectpath="lib.jar"/>
                <run class="PerCFlowCompileFromJarTest"/>
        </ajc-test>
+       
+       <ajc-test dir="bugs/throwsSignature"
+               pr="42539"
+               title="throw derivative pointcuts not advised">
+               <compile files="ExceptionBugTest.java,ExceptionAspect.java">
+                   <message line="5" kind="warning" text="throws both"/>
+                   <message line="5" kind="error" text="throws Exception"/>
+                   <message line="7" kind="warning" text="throws both"/>
+               </compile>
+       </ajc-test>
 </suite>
diff --git a/tests/bugs/throwsSignature/ExceptionAspect.java b/tests/bugs/throwsSignature/ExceptionAspect.java
new file mode 100644 (file)
index 0000000..db15fcb
--- /dev/null
@@ -0,0 +1,10 @@
+public aspect ExceptionAspect
+{
+    pointcut exceptionThrower() :
+        execution(public * ExceptionBugTest.*(..) throws Exception+);
+
+    declare warning : exceptionThrower() : "throws both";
+    
+    declare error : execution(public * ExceptionBugTest.*(..) throws Exception) : 
+        "throws Exception";
+}
\ No newline at end of file
diff --git a/tests/bugs/throwsSignature/ExceptionBugTest.java b/tests/bugs/throwsSignature/ExceptionBugTest.java
new file mode 100644 (file)
index 0000000..e77f283
--- /dev/null
@@ -0,0 +1,8 @@
+public class ExceptionBugTest {
+    int x;
+    class MyException extends Exception {}
+
+    public void method1() throws Exception { x = 1; } // warning here
+
+    public void method2() throws MyException { x = 2; } // warning here
+}
\ No newline at end of file
index 2b6be4863217ba0ac9c0083cf929457a854b5310..5de0c16b7eb424cd59161ffeb46ef3deec785a5d 100644 (file)
@@ -91,7 +91,7 @@ public class ThrowsPattern extends PatternNode {
                ResolvedTypeX[] types) 
        {
                for (int i = types.length - 1; i >= 0; i--) {
-                       if (typePattern.matchesExactly(types[i])) return true;  
+                       if (typePattern.matchesStatically(types[i])) return true;       
                }
                return false;
        }