diff options
Diffstat (limited to 'tests/bugs153/pr162135/Real.java')
-rw-r--r-- | tests/bugs153/pr162135/Real.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/bugs153/pr162135/Real.java b/tests/bugs153/pr162135/Real.java new file mode 100644 index 000000000..bc64ef80c --- /dev/null +++ b/tests/bugs153/pr162135/Real.java @@ -0,0 +1,47 @@ +package a.b.c; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; + + +class Foo { + public void m() { + throw new RuntimeException("Hello World"); + } + + +} +@Aspect +public class Real { + + public static void main(String []argv) { + try { + new Foo().m(); + } catch (Throwable t) { + System.out.println(t.getMessage()); + } + } + + @Pointcut("call(Throwable+.new(String, ..)) && this(caller) && args(exceptionMessage) && if()") + public static boolean exceptionInitializer(Object caller, String exceptionMessage) { + return isNdcEmpty(); + } + + @Around("exceptionInitializer(caller, exceptionMessage)") + public Object annotateException(ProceedingJoinPoint jp, Object caller, String exceptionMessage) { + System.out.println("advice running"); + return jp.proceed(new Object[]{caller, "newmessage"}); + } + + private static boolean isNdcEmpty() { + return NDC.getDepth() == 0; + } + +} + + +class NDC { + public static int getDepth() { return 0; } +} |