]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bugzilla Bug 49638 exception logging: after() throwing advice can't convert...
authorjhugunin <jhugunin>
Fri, 9 Jan 2004 09:21:03 +0000 (09:21 +0000)
committerjhugunin <jhugunin>
Fri, 9 Jan 2004 09:21:03 +0000 (09:21 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/AjParser.java
tests/ajcTests.xml
tests/bugs/AfterThrowingAdviceSyntaxError.java [new file with mode: 0644]

index 621576e16dcc01eee51b052b5de9c735b9a3b7ca..819de5523f4f00a8fc2f6f54e3d171dc74927ad0 100644 (file)
@@ -737,7 +737,12 @@ public class AjParser extends Parser {
            } else if (CharOperation.equals(name, "returning".toCharArray())) {
                adviceDecl.kind = AdviceKind.AfterReturning;
            } else {
-               //XXX illegal name here
+                       problemReporter().parseError(
+                               start, 
+                               end, 
+                               name, 
+                               String.valueOf(name), 
+                               new String[] {"throwing", "returning", ":"}); 
            }
        }
 
index 241d59ccc9e15aa85695e17d28c7685a4c03196a..c99ab74c692386444f7db37978a547e18243fe5f 100644 (file)
                        </message>
                </compile>
        </ajc-test>
-   
+
+       <ajc-test dir="bugs"
+               title="Appropriate message for 'after() thowing(Throwable th)' syntax error"
+               pr="49638"
+               >
+               <compile 
+                       files="AfterThrowingAdviceSyntaxError.java" >
+                       <message kind="error" line="21" />
+                       <message kind="error" line="23" />
+               </compile>
+       </ajc-test>
+    
 </suite>
diff --git a/tests/bugs/AfterThrowingAdviceSyntaxError.java b/tests/bugs/AfterThrowingAdviceSyntaxError.java
new file mode 100644 (file)
index 0000000..088dcdc
--- /dev/null
@@ -0,0 +1,28 @@
+import org.aspectj.lang.*;
+
+public class AfterThrowingAdviceSyntaxError {
+
+       public static void main(String[] args) {
+               perform();
+       }
+
+       private static void perform() {
+               Object nullObj = null;
+               nullObj.toString();
+       }
+}
+
+aspect ExceptionLoggerAspectV2 
+{
+
+       pointcut exceptionLogMethods()
+               : call(* *.*(..)) && !within(ExceptionLoggerAspectV2);
+
+       after() thowing(Throwable ex) : exceptionLogMethods() {
+               Signature sig = thisJoinPointStaticPart.getSignature();
+               System.out.printl("WARNING: " 
+                       + sig.getDeclaringType().getName() + " "
+                       + sig.getName() + " "
+                       + "Exception logger aspect " + ex);
+       }
+}
\ No newline at end of file