From f8bedd567528dd918128b5ca6df0617136ff4994 Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 4 Dec 2008 23:39:08 +0000 Subject: [PATCH] 162135: test and fix --- tests/bugs153/pr162135/Foo.java | 4 ++ tests/bugs153/pr162135/Foo6.java | 30 ++++++++++++ tests/bugs153/pr162135/Real.java | 47 +++++++++++++++++++ .../systemtest/ajc153/Ajc153Tests.java | 33 +++++++++++-- .../org/aspectj/systemtest/ajc153/ajc153.xml | 26 +++++++++- 5 files changed, 134 insertions(+), 6 deletions(-) create mode 100644 tests/bugs153/pr162135/Foo6.java create mode 100644 tests/bugs153/pr162135/Real.java 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 @@ - + + + + + @@ -52,6 +56,26 @@ + + + + + + + + + + + + + + + + + + + + -- 2.39.5