aboutsummaryrefslogtreecommitdiffstats
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
parent024421468c163588ec7d2d2d5dfa13b8dea4bb1e (diff)
downloadaspectj-f8bedd567528dd918128b5ca6df0617136ff4994.tar.gz
aspectj-f8bedd567528dd918128b5ca6df0617136ff4994.zip
162135: test and fix
-rw-r--r--tests/bugs153/pr162135/Foo.java4
-rw-r--r--tests/bugs153/pr162135/Foo6.java30
-rw-r--r--tests/bugs153/pr162135/Real.java47
-rw-r--r--tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java33
-rw-r--r--tests/src/org/aspectj/systemtest/ajc153/ajc153.xml26
5 files changed, 134 insertions, 6 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; }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
index 1d4f30ac0..5fca46ebf 100644
--- a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
@@ -34,11 +34,34 @@ public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
// public void testCFlowXMLAspectLTW_pr149096() { runTest("cflow xml concrete aspect"); }
// public void testAmbiguousBinding_pr121805() { runTest("ambiguous binding");}
// public void testNegatedAnnotationMatchingProblem_pr153464() { runTest("negated annotation matching problem");}
- // public void testAnnotationStyleBcException_pr162135() { runTest("bcexception in annotation style around advice");}
- // public void testAnnotationStyleBcException_pr162135_2() { runTest("bcexception in annotation style around advice - 2");}
- // public void testAnnotationStyleBcException_pr162135_3() { runTest("bcexception in annotation style around advice - 3");}
- // public void testAnnotationStyleBcException_pr162135_4() { runTest("bcexception in annotation style around advice - 4");}
- // public void testAnnotationStyleBcException_pr162135_5() { runTest("bcexception in annotation style around advice - 5");}
+ public void testAnnotationStyleBcException_pr162135() {
+ runTest("bcexception in annotation style around advice");
+ }
+
+ public void testAnnotationStyleBcException_pr162135_2() {
+ runTest("bcexception in annotation style around advice - 2");
+ }
+
+ public void testAnnotationStyleBcException_pr162135_3() {
+ runTest("bcexception in annotation style around advice - 3");
+ }
+
+ public void testAnnotationStyleBcException_pr162135_4() {
+ runTest("bcexception in annotation style around advice - 4");
+ }
+
+ public void testAnnotationStyleBcException_pr162135_5() {
+ runTest("bcexception in annotation style around advice - 5");
+ }
+
+ public void testAnnotationStyleBcException_pr162135_6() {
+ runTest("bcexception in annotation style around advice - 6");
+ }
+
+ public void testAnnotationStyleBcException_pr162135_7() {
+ runTest("bcexception in annotation style around advice - 7");
+ }
+
public void testIncompatibleClassChangeWithITD_pr164633() {
runTest("incompatibleclasschange");
}
diff --git a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
index 1b235854e..a74742c71 100644
--- a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
+++ b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
@@ -21,7 +21,11 @@
<ajc-test dir="bugs153/pr162135" title="bcexception in annotation style around advice">
<compile files="Foo.java" options="-1.5"/>
- <run class="Foo"/>
+ <run class="Foo">
+ <stdout>
+ <line text="In if(), is there a caller? yes"/>
+ </stdout>
+ </run>
</ajc-test>
<ajc-test dir="bugs153/pr162657" title="complex pointcut">
@@ -52,6 +56,26 @@
<compile files="Foo5.java" options="-1.5"/>
<run class="Foo5"/>
</ajc-test>
+
+ <ajc-test dir="bugs153/pr162135" title="bcexception in annotation style around advice - 6">
+ <compile files="Foo6.java" options="-1.5"/>
+ <run class="Foo6">
+ <stdout>
+ <line text="ProceedingJoinPoint is call(java.lang.RuntimeException(String))"/>
+ <line text="caller is notnull"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs153/pr162135" title="bcexception in annotation style around advice - 7">
+ <compile files="Real.java" options="-1.5"/>
+ <run class="a.b.c.Real">
+ <stdout>
+ <line text="advice running"/>
+ <line text="newmessage"/>
+ </stdout>
+ </run>
+ </ajc-test>
<ajc-test dir="bugs153/pr159143" title="declare method annotations">
<compile files="DeclareMethodAnnotation.java" options="-1.5">