aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs153
diff options
context:
space:
mode:
authoraclement <aclement>2008-12-04 23:39:08 +0000
committeraclement <aclement>2008-12-04 23:39:08 +0000
commitf8bedd567528dd918128b5ca6df0617136ff4994 (patch)
tree41f2c6fa6818600b41cd8b3b329bd41f091fc68c /tests/bugs153
parent024421468c163588ec7d2d2d5dfa13b8dea4bb1e (diff)
downloadaspectj-f8bedd567528dd918128b5ca6df0617136ff4994.tar.gz
aspectj-f8bedd567528dd918128b5ca6df0617136ff4994.zip
162135: test and fix
Diffstat (limited to 'tests/bugs153')
-rw-r--r--tests/bugs153/pr162135/Foo.java4
-rw-r--r--tests/bugs153/pr162135/Foo6.java30
-rw-r--r--tests/bugs153/pr162135/Real.java47
3 files changed, 81 insertions, 0 deletions
diff --git a/tests/bugs153/pr162135/Foo.java b/tests/bugs153/pr162135/Foo.java
index df4211a4b..0d408e3c8 100644
--- a/tests/bugs153/pr162135/Foo.java
+++ b/tests/bugs153/pr162135/Foo.java
@@ -6,15 +6,19 @@ import org.aspectj.lang.annotation.Pointcut;
@Aspect public class Foo {
+ static class X {
public void m() {
new RuntimeException("hello");
}
+ }
public static void main(String[] argv) {
+ new X().m();
}
@Pointcut("call(Throwable+.new(String, ..)) && this(caller) && if()")
public static boolean exceptionInitializer(Object caller) {
+ System.out.println("In if(), is there a caller? "+(caller!=null?"yes":"no"));
return true;
}
diff --git a/tests/bugs153/pr162135/Foo6.java b/tests/bugs153/pr162135/Foo6.java
new file mode 100644
index 000000000..16f125ef7
--- /dev/null
+++ b/tests/bugs153/pr162135/Foo6.java
@@ -0,0 +1,30 @@
+import java.lang.reflect.Field;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+
+@Aspect public class Foo6 {
+
+ public void m() {
+ new RuntimeException("hello");
+ }
+
+ public static void main(String[] argv) {
+ try {
+ new Foo6().m();
+ } catch (Throwable t) {}
+ }
+
+ @Pointcut("call(Throwable+.new(String, ..)) && this(caller) && if()")
+ public static boolean exceptionInitializer(Object caller) {
+ return true;
+ }
+
+ @Around("exceptionInitializer(caller)")
+ public Object annotateException(ProceedingJoinPoint jp, Object caller) {
+ System.out.println("ProceedingJoinPoint is "+jp);
+ System.out.println("caller is "+(caller==null?"null":"notnull"));
+ return null;
+ }
+}
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; }
+}