From b794e2a851cfe3219159ae078a6c76f05753827f Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 11 Jun 2008 19:40:32 +0000 Subject: [PATCH] 197719: second testcase --- tests/bugs161/pr197719/test/aspects/C1.java | 15 +++++++ tests/bugs161/pr197719/test/aspects/C3.java | 42 +++++++++++++++++++ .../bugs161/pr197719/test/aspects/MyAnn.java | 13 ++++++ .../pr197719/test/aspects/MyAnnAspect.java | 24 +++++++++++ tests/bugs161/pr197719/test/aspects2/C2.java | 34 +++++++++++++++ .../systemtest/ajc161/Ajc161Tests.java | 1 + .../org/aspectj/systemtest/ajc161/ajc161.xml | 21 ++++++++++ 7 files changed, 150 insertions(+) create mode 100644 tests/bugs161/pr197719/test/aspects/C1.java create mode 100644 tests/bugs161/pr197719/test/aspects/C3.java create mode 100644 tests/bugs161/pr197719/test/aspects/MyAnn.java create mode 100644 tests/bugs161/pr197719/test/aspects/MyAnnAspect.java create mode 100644 tests/bugs161/pr197719/test/aspects2/C2.java diff --git a/tests/bugs161/pr197719/test/aspects/C1.java b/tests/bugs161/pr197719/test/aspects/C1.java new file mode 100644 index 000000000..a82ab4c8f --- /dev/null +++ b/tests/bugs161/pr197719/test/aspects/C1.java @@ -0,0 +1,15 @@ +package test.aspects; + + +public class C1 { + + @MyAnn + protected void aMethod() { + System.out.println("Calling aMethod"); + } + + public void callAMethod() { + aMethod(); // Should be a marker here... + } + +} diff --git a/tests/bugs161/pr197719/test/aspects/C3.java b/tests/bugs161/pr197719/test/aspects/C3.java new file mode 100644 index 000000000..64a5ba035 --- /dev/null +++ b/tests/bugs161/pr197719/test/aspects/C3.java @@ -0,0 +1,42 @@ +package test.aspects; + +import test.aspects2.C2; + + +public class C3 { + + public void callAMethodC2() { + C1 c1 = new C1(); + c1.aMethod(); // Should be a marker here... + + C2 c2 = new C2(); + c2.aMethod(); // Should be a marker here... + } + + public void innerClassCall() { + InnerClass ic = new InnerClass(); + + ic.foo(); + } + protected class InnerClass { + public void foo() { + C1 c1 = new C1(); + c1.aMethod(); // Should be a marker here... + + C2 c2 = new C2(); + c2.aMethod(); // Should be a marker here... + } + } + + public static void main(String [] args) { + C1 c1 = new C1(); + + c1.aMethod(); // Should be a marker here... + c1.callAMethod(); + + C3 c2 = new C3(); + + c2.callAMethodC2(); + c2.innerClassCall(); + } +} diff --git a/tests/bugs161/pr197719/test/aspects/MyAnn.java b/tests/bugs161/pr197719/test/aspects/MyAnn.java new file mode 100644 index 000000000..ccad57dad --- /dev/null +++ b/tests/bugs161/pr197719/test/aspects/MyAnn.java @@ -0,0 +1,13 @@ +package test.aspects; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Inherited +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface MyAnn { +} diff --git a/tests/bugs161/pr197719/test/aspects/MyAnnAspect.java b/tests/bugs161/pr197719/test/aspects/MyAnnAspect.java new file mode 100644 index 000000000..83a12e1c3 --- /dev/null +++ b/tests/bugs161/pr197719/test/aspects/MyAnnAspect.java @@ -0,0 +1,24 @@ +package test.aspects; + +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 MyAnnAspect { + + @Pointcut("call(@MyAnn * *(..))") + void validatedMethod() {} + + + @Around("validatedMethod()") + public Object validateMethodImpl(ProceedingJoinPoint thisJoinPoint) throws Throwable { + return doInvoke(thisJoinPoint); + } + + private Object doInvoke(final ProceedingJoinPoint thisJoinPoint) throws Throwable { + System.out.println("Invoking : " + thisJoinPoint+ " "+thisJoinPoint.getTarget().getClass().getName()); + return thisJoinPoint.proceed(); + } +} diff --git a/tests/bugs161/pr197719/test/aspects2/C2.java b/tests/bugs161/pr197719/test/aspects2/C2.java new file mode 100644 index 000000000..93361ba5e --- /dev/null +++ b/tests/bugs161/pr197719/test/aspects2/C2.java @@ -0,0 +1,34 @@ +package test.aspects2; + +import test.aspects.C1; + + +public class C2 extends C1 { + public void callAMethodC2() { + aMethod(); // Should be a marker here... + } + + public void innerClassCall() { + InnerClass ic = new InnerClass(); + + ic.foo(); + } + protected class InnerClass { + public void foo() { + aMethod(); // Should be a marker here... + } + } + + public static void main(String [] args) { + C1 c1 = new C1(); + + c1.callAMethod(); + + C2 c2 = new C2(); + + c2.aMethod(); // Should be a marker here... + c2.callAMethod(); + c2.callAMethodC2(); + c2.innerClassCall(); + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc161/Ajc161Tests.java b/tests/src/org/aspectj/systemtest/ajc161/Ajc161Tests.java index ed8cd9f32..04551984b 100644 --- a/tests/src/org/aspectj/systemtest/ajc161/Ajc161Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc161/Ajc161Tests.java @@ -23,6 +23,7 @@ import org.aspectj.testing.XMLBasedAjcTestCase; public class Ajc161Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // AspectJ1.6.1 + public void testProtectedMethodsAroundAdvice_pr197719_2() { runTest("protected methods and around advice - again - 2");} public void testProtectedMethodsAroundAdvice_pr197719() { runTest("protected methods and around advice - again");} public void testProtectedMethodsAroundAdvice_pr230075() { runTest("protected methods and around advice");} public void testFinalStringsAnnotationPointcut_pr174385() { runTest("static strings in annotation pointcuts");} diff --git a/tests/src/org/aspectj/systemtest/ajc161/ajc161.xml b/tests/src/org/aspectj/systemtest/ajc161/ajc161.xml index 0265aa7d7..59838531e 100644 --- a/tests/src/org/aspectj/systemtest/ajc161/ajc161.xml +++ b/tests/src/org/aspectj/systemtest/ajc161/ajc161.xml @@ -3,6 +3,27 @@ + + + + + + + + + + + + + + + + + + + + + -- 2.39.5