]> source.dussan.org Git - aspectj.git/commitdiff
Fix and tests for pr84312: runtime retention checking. From Andrew Huff.
authoraclement <aclement>
Thu, 12 May 2005 13:00:07 +0000 (13:00 +0000)
committeraclement <aclement>
Thu, 12 May 2005 13:00:07 +0000 (13:00 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java
tests/java5/annotations/thisOrtarget/NotRuntimeRetention.aj
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
weaver/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java

index 826e585f2155959776bd67c21f65db1e59a14d3d..2b9c61fbe76c87592f7ede91bb23291b4e5d7096 100644 (file)
@@ -280,7 +280,7 @@ public class EclipseSourceType extends ResolvedTypeX.ConcreteName {
            if (!isAnnotation()) {
                return false;
            } else {
-               return (binding.getAnnotationTagBits() & TagBits.AnnotationRuntimeRetention)!=0;        
+                  return (binding.getAnnotationTagBits() & TagBits.AnnotationRetentionMASK) == TagBits.AnnotationRuntimeRetention;        
            }
        }
        
index 03728c59948ce6bb702142d17155eb8c10970d38..bbd986f8a1fa24623a0d64e12d0c0b3f08f622a2 100644 (file)
@@ -1,18 +1,23 @@
-public aspect NotRuntimeRetention {
-    
-    pointcut doSomethingExecution() : execution(* doSomething());
-    pointcut doSomethingCall() : call(* doSomething());
-    
-    // CE L7
-    before() : doSomethingExecution() && @this(MyClassRetentionAnnotation) {
-       // should be compile-time error!
-        System.out.println("How did I get here?");
-    }
-    
-    // CE L13
-    after() returning : doSomethingCall() && @target(MyClassRetentionAnnotation) {
-       // should be compile-time error!
-        System.out.println("How did I get here?");
-    }
-    
-}
\ No newline at end of file
+//"must have runtime retention"
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface MyRuntimeAnnotation {}
+
+@Retention(RetentionPolicy.SOURCE)
+@interface MySourceAnnotation {}
+
+@Retention(RetentionPolicy.CLASS)
+@interface MyClassAnnotation {}
+
+@interface MyAnnotation {}
+
+aspect X {
+ @MyRuntimeAnnotation @MySourceAnnotation @MyClassAnnotation @MyAnnotation
+ void a(){}
+ before(MyRuntimeAnnotation a): execution(* *(..)) && @annotation(a) {} // no error
+ before(MySourceAnnotation a): execution(* *(..)) && @annotation(a) {} // error expected
+ before(MyClassAnnotation a): execution(* *(..)) && @annotation(a) {} // error expected
+ before(MyAnnotation a): execution(* *(..)) && @annotation(a) {} // error expected
+}
index 6a5222ae67b5747640ba0d4b63a18a26de7534dc..2bb4efb9564e8f6cb217a636b91f609db511a870 100644 (file)
     </ajc-test>   
     
     <ajc-test dir="java5/annotations/thisOrtarget" vm="1.5" title="must have runtime retention">
-        <compile options="-1.5" files="TestingAnnotations.java,NotRuntimeRetention.aj">
-               <message kind="error" line="7" text="Annotation type MyClassRetentionAnnotation does not have runtime retention"/>
-               <message kind="error" line="13" text="Annotation type MyClassRetentionAnnotation does not have runtime retention"/>
+        <compile options="-1.5" files="NotRuntimeRetention.aj">
+         <message kind="error" line="20" text="Annotation type MySourceAnnotation does not have runtime retention"/>
+            <message kind="error" line="21" text="Annotation type MyClassAnnotation does not have runtime retention"/>
+            <message kind="error" line="22" text="Annotation type MyAnnotation does not have runtime retention"/>
         </compile>
     </ajc-test>
      
index 3d8ad311fdfac1e5dfa2b22fb234f930b259dbc6..d32f9184b871c51889b42a4a4b7dfb2b467fad91 100644 (file)
@@ -50,22 +50,13 @@ public class BindingAnnotationTypePattern extends ExactAnnotationTypePattern imp
                        world.getMessageHandler().handleMessage(m);
                        resolved = false;
                }
-               if (!annotationType.hasAnnotation(TypeX.AT_RETENTION)) {
+        if (!annotationType.isAnnotationWithRuntimeRetention(world)) { // default is class visibility
                    // default is class visibility
                        IMessage m = MessageUtil.error(
                                        WeaverMessages.format(WeaverMessages.BINDING_NON_RUNTIME_RETENTION_ANNOTATION,annotationType.getName()),
                                        getSourceLocation());
                        world.getMessageHandler().handleMessage(m);
                        resolved = false;                   
-               } else {
-                   // Get the retention policy annotation, and check the value is RetentionPolicy.RUNTIME;
-                       // FIXME asc invention required, implement this !
-//                     if (!annotationType.hasRuntimeRetention()) {
-//                     ResolvedTypeX[] allAs = annotationType.getAnnotationTypes();
-//                     for (int i = 0; i < allAs.length; i++) {
-//                             ResolvedTypeX  ann = allAs[i];
-//                             if ()
-//                     }
                }
        }