From 42b451fbb6dd1306a3fe5da7000d3d02f1f21b0a Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 24 Apr 2009 21:23:47 +0000 Subject: [PATCH] 273628: test and fix: use of if() pointcut in annotation style with annotation value binding! --- tests/bugs165/pr273628/AnnotationAspect.java | 31 +++++++++++++++++++ tests/bugs165/pr273628/ApiDescriptor.java | 11 +++++++ tests/bugs165/pr273628/AspectTargetClass.java | 11 +++++++ tests/bugs165/pr273628/MonitorableMethod.java | 15 +++++++++ .../TestPointcutAnnotationAspect.java | 18 +++++++++++ .../systemtest/ajc165/Ajc165Tests.java | 4 +++ .../org/aspectj/systemtest/ajc165/ajc165.xml | 5 +++ 7 files changed, 95 insertions(+) create mode 100644 tests/bugs165/pr273628/AnnotationAspect.java create mode 100644 tests/bugs165/pr273628/ApiDescriptor.java create mode 100644 tests/bugs165/pr273628/AspectTargetClass.java create mode 100644 tests/bugs165/pr273628/MonitorableMethod.java create mode 100644 tests/bugs165/pr273628/TestPointcutAnnotationAspect.java diff --git a/tests/bugs165/pr273628/AnnotationAspect.java b/tests/bugs165/pr273628/AnnotationAspect.java new file mode 100644 index 000000000..b232887a7 --- /dev/null +++ b/tests/bugs165/pr273628/AnnotationAspect.java @@ -0,0 +1,31 @@ +package p; + +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 AnnotationAspect +{ + @Pointcut("if() && execution(@MonitorableMethod public * p..*(..)) && @annotation(MonitorableMethod(api))") + public static boolean adviseIfMonitoringPartialAnnotation(ApiDescriptor api) { + return true; + } + + @Around("adviseIfMonitoringPartialAnnotation(api)") + public Object monitorMethodPerformancePartialAnnotation(ProceedingJoinPoint pjp, ApiDescriptor api) + throws Throwable { + System.out.println("Descriptor value: " + api.number); + return pjp.proceed(); + } + +// +// pointcut p(ApiDescriptor api): if(true) && execution(@MonitorableMethod public * p..*(..)) && @annotation(MonitorableMethod(api)); +// +// Object around(ApiDescriptor api): p(api) { +// System.out.println("Descriptor value: " + api.number); +// return proceed(); +// } + +} diff --git a/tests/bugs165/pr273628/ApiDescriptor.java b/tests/bugs165/pr273628/ApiDescriptor.java new file mode 100644 index 000000000..de103b030 --- /dev/null +++ b/tests/bugs165/pr273628/ApiDescriptor.java @@ -0,0 +1,11 @@ +package p; + +public enum ApiDescriptor { + TARGET_CLASS_TARGET_METHOD(999); + + ApiDescriptor(int number) { + this.number = number; + } + + public final int number; +} diff --git a/tests/bugs165/pr273628/AspectTargetClass.java b/tests/bugs165/pr273628/AspectTargetClass.java new file mode 100644 index 000000000..2d9774250 --- /dev/null +++ b/tests/bugs165/pr273628/AspectTargetClass.java @@ -0,0 +1,11 @@ +package p; + + +public class AspectTargetClass +{ + @MonitorableMethod(ApiDescriptor.TARGET_CLASS_TARGET_METHOD) + public void aspectTargetMethod() + { + System.out.println("In target method"); + } +} diff --git a/tests/bugs165/pr273628/MonitorableMethod.java b/tests/bugs165/pr273628/MonitorableMethod.java new file mode 100644 index 000000000..667856324 --- /dev/null +++ b/tests/bugs165/pr273628/MonitorableMethod.java @@ -0,0 +1,15 @@ +package p; + +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 MonitorableMethod +{ + ApiDescriptor value(); +} diff --git a/tests/bugs165/pr273628/TestPointcutAnnotationAspect.java b/tests/bugs165/pr273628/TestPointcutAnnotationAspect.java new file mode 100644 index 000000000..389054bb9 --- /dev/null +++ b/tests/bugs165/pr273628/TestPointcutAnnotationAspect.java @@ -0,0 +1,18 @@ +package p; + +public class TestPointcutAnnotationAspect +{ + public static void main(String[] args) + { + AspectTargetClass c = new AspectTargetClass(); + try + { + c.aspectTargetMethod(); + } + catch ( Exception e ) + { + e.printStackTrace(); + } +// System.exit(0); + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java b/tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java index ccad2d7de..e405210f1 100644 --- a/tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java @@ -20,6 +20,10 @@ import org.aspectj.weaver.LintMessage; public class Ajc165Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testVerifyOnAnnoBind_pr273628() { + runTest("verifyerror on anno bind"); + } + public void testFunkyPointcut_pr272233() { runTest("funky pointcut"); } diff --git a/tests/src/org/aspectj/systemtest/ajc165/ajc165.xml b/tests/src/org/aspectj/systemtest/ajc165/ajc165.xml index 42a99cd1b..723a4e0ce 100644 --- a/tests/src/org/aspectj/systemtest/ajc165/ajc165.xml +++ b/tests/src/org/aspectj/systemtest/ajc165/ajc165.xml @@ -26,5 +26,10 @@ + + + + + \ No newline at end of file -- 2.39.5