From 8f9ad80b4e0ed4518761c8ab9e81df68cf145c1e Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 22 Aug 2008 17:09:16 +0000 Subject: 197720: test and fix: annotation matching on parameterized member --- tests/bugs162/pr197720/C1.java | 15 +++++++++++++ tests/bugs162/pr197720/C2.java | 34 ++++++++++++++++++++++++++++ tests/bugs162/pr197720/C3.java | 40 +++++++++++++++++++++++++++++++++ tests/bugs162/pr197720/MyAnn.java | 13 +++++++++++ tests/bugs162/pr197720/MyAnnAspect.java | 24 ++++++++++++++++++++ 5 files changed, 126 insertions(+) create mode 100644 tests/bugs162/pr197720/C1.java create mode 100644 tests/bugs162/pr197720/C2.java create mode 100644 tests/bugs162/pr197720/C3.java create mode 100644 tests/bugs162/pr197720/MyAnn.java create mode 100644 tests/bugs162/pr197720/MyAnnAspect.java (limited to 'tests/bugs162') diff --git a/tests/bugs162/pr197720/C1.java b/tests/bugs162/pr197720/C1.java new file mode 100644 index 000000000..999190c77 --- /dev/null +++ b/tests/bugs162/pr197720/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/bugs162/pr197720/C2.java b/tests/bugs162/pr197720/C2.java new file mode 100644 index 000000000..c1673fbbb --- /dev/null +++ b/tests/bugs162/pr197720/C2.java @@ -0,0 +1,34 @@ +package test.aspects; + + + +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/bugs162/pr197720/C3.java b/tests/bugs162/pr197720/C3.java new file mode 100644 index 000000000..6d30b3a78 --- /dev/null +++ b/tests/bugs162/pr197720/C3.java @@ -0,0 +1,40 @@ +package test.aspects; + + + +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/bugs162/pr197720/MyAnn.java b/tests/bugs162/pr197720/MyAnn.java new file mode 100644 index 000000000..ccad57dad --- /dev/null +++ b/tests/bugs162/pr197720/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/bugs162/pr197720/MyAnnAspect.java b/tests/bugs162/pr197720/MyAnnAspect.java new file mode 100644 index 000000000..54cbb6ac3 --- /dev/null +++ b/tests/bugs162/pr197720/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); + return thisJoinPoint.proceed(); + } +} -- cgit v1.2.3