From 7b081f2e0bece3414ac4f385cde75d7b54981099 Mon Sep 17 00:00:00 2001 From: jhugunin Date: Fri, 9 Jan 2004 09:21:03 +0000 Subject: [PATCH] Fix for Bugzilla Bug 49638 exception logging: after() throwing advice can't convert Throwable obj to string and ajc aborts --- .../internal/compiler/parser/AjParser.java | 7 ++++- tests/ajcTests.xml | 13 ++++++++- .../bugs/AfterThrowingAdviceSyntaxError.java | 28 +++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 tests/bugs/AfterThrowingAdviceSyntaxError.java diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/AjParser.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/AjParser.java index 621576e16..819de5523 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/AjParser.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/AjParser.java @@ -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", ":"}); } } diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index 241d59ccc..c99ab74c6 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -6897,5 +6897,16 @@ - + + + + + + + + diff --git a/tests/bugs/AfterThrowingAdviceSyntaxError.java b/tests/bugs/AfterThrowingAdviceSyntaxError.java new file mode 100644 index 000000000..088dcdc9a --- /dev/null +++ b/tests/bugs/AfterThrowingAdviceSyntaxError.java @@ -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 -- 2.39.5