} 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", ":"});
}
}
</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>
--- /dev/null
+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