]> source.dussan.org Git - aspectj.git/commitdiff
273628: test and fix: use of if() pointcut in annotation style with annotation value...
authoraclement <aclement>
Fri, 24 Apr 2009 21:23:47 +0000 (21:23 +0000)
committeraclement <aclement>
Fri, 24 Apr 2009 21:23:47 +0000 (21:23 +0000)
tests/bugs165/pr273628/AnnotationAspect.java [new file with mode: 0644]
tests/bugs165/pr273628/ApiDescriptor.java [new file with mode: 0644]
tests/bugs165/pr273628/AspectTargetClass.java [new file with mode: 0644]
tests/bugs165/pr273628/MonitorableMethod.java [new file with mode: 0644]
tests/bugs165/pr273628/TestPointcutAnnotationAspect.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java
tests/src/org/aspectj/systemtest/ajc165/ajc165.xml

diff --git a/tests/bugs165/pr273628/AnnotationAspect.java b/tests/bugs165/pr273628/AnnotationAspect.java
new file mode 100644 (file)
index 0000000..b232887
--- /dev/null
@@ -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 (file)
index 0000000..de103b0
--- /dev/null
@@ -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 (file)
index 0000000..2d97742
--- /dev/null
@@ -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 (file)
index 0000000..6678563
--- /dev/null
@@ -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 (file)
index 0000000..389054b
--- /dev/null
@@ -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);
+    }
+}
index ccad2d7dee775fd1869fb5d1dd9e6adbdf5be709..e405210f1d550f28053d068588dfc59f00fa29e8 100644 (file)
@@ -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");
        }
index 42a99cd1be889a011ea1f98f71676a782b754125..723a4e0ce60fd23b7b41ef6ac33e16c9aa4d6a4d 100644 (file)
    <ajc-test dir="bugs165/pr271169" title="around call npe">
      <compile files="HypChecksums.java" options="-1.5"/>
    </ajc-test>
+   
+   <ajc-test dir="bugs165/pr273628" title="verifyerror on anno bind">
+     <compile files="AnnotationAspect.java ApiDescriptor.java AspectTargetClass.java MonitorableMethod.java TestPointcutAnnotationAspect.java" options="-1.5"/>
+     <run class="p.TestPointcutAnnotationAspect"/>
+   </ajc-test>
 
 </suite>
\ No newline at end of file