]> source.dussan.org Git - aspectj.git/commitdiff
286539: test and fix (decanno type in model)
authoraclement <aclement>
Thu, 13 Aug 2009 17:29:13 +0000 (17:29 +0000)
committeraclement <aclement>
Thu, 13 Aug 2009 17:29:13 +0000 (17:29 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareAnnotation.java

index 9757bbdae757f814c9a6386f3e7fcf1152b29be4..668d7ebaa99394c5465919e931cdad1c4b6267ff 100644 (file)
@@ -42,6 +42,7 @@ public class DeclareAnnotation extends Declare {
        private String annotationString = "@<annotation>";
        private ResolvedType containingAspect;
        private AnnotationAJ annotation;
+       private ResolvedType annotationType;
 
        /**
         * Captures type of declare annotation (method/type/field/constructor)
@@ -309,7 +310,13 @@ public class DeclareAnnotation extends Declare {
                                        // if weaving broken code, this can happen
                                        return;
                                }
-                               annotation = annos[0];
+                               int idx = 0;
+                               if (annos.length > 0
+                                               && annos[0].getType().getSignature().equals("Lorg/aspectj/internal/lang/annotation/ajcDeclareAnnotation;")) {
+                                       idx = 1;
+                               }
+                               annotation = annos[idx];
+                               break;
                        }
                }
        }
@@ -351,11 +358,28 @@ public class DeclareAnnotation extends Declare {
        }
 
        /**
-        * @return UnresolvedType for the annotation
+        * @return the type of the annotation
         */
-       public UnresolvedType getAnnotationTypeX() {
-               ensureAnnotationDiscovered();
-               return (this.annotation == null ? null : this.annotation.getType());
+       public ResolvedType getAnnotationType() {
+               if (annotationType == null) {
+                       for (Iterator iter = containingAspect.getMethods(); iter.hasNext();) {
+                               ResolvedMember member = (ResolvedMember) iter.next();
+                               if (member.getName().equals(annotationMethod)) {
+                                       ResolvedType[] annoTypes = member.getAnnotationTypes();
+                                       if (annoTypes == null) {
+                                               // if weaving broken code, this can happen
+                                               return null;
+                                       }
+                                       int idx = 0;
+                                       if (annoTypes[0].getSignature().equals("Lorg/aspectj/internal/lang/annotation/ajcDeclareAnnotation;")) {
+                                               idx = 1;
+                                       }
+                                       annotationType = annoTypes[idx];
+                                       break;
+                               }
+                       }
+               }
+               return annotationType;
        }
 
        /**