]> source.dussan.org Git - aspectj.git/commitdiff
@within, @withincode fixes
authoracolyer <acolyer>
Fri, 10 Dec 2004 13:21:38 +0000 (13:21 +0000)
committeracolyer <acolyer>
Fri, 10 Dec 2004 13:21:38 +0000 (13:21 +0000)
weaver/src/org/aspectj/weaver/ResolvedMember.java
weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java

index 138f12f5cc2578f764356721a2240afa2efaecc2..90b8b59e9e2375ea28dfaecb6fdbc1f2007829ad 100644 (file)
@@ -102,7 +102,7 @@ public class ResolvedMember extends Member implements IHasPosition, AnnotatedEle
        return true;
     }
 
-    public boolean hasAnnotation(ResolvedTypeX ofType) {
+    public boolean hasAnnotation(TypeX ofType) {
         // The ctors don't allow annotations to be specified ... yet - but
         // that doesn't mean it is an error to call this method.
         // Normally the weaver will be working with subtypes of 
index f763bfafc8f68ee251d74feb8806acb7dd2d39b3..946cdc99c00b38d3d9da0c228b2d72aa1d36aaba 100644 (file)
@@ -38,6 +38,7 @@ import org.aspectj.weaver.ast.Var;
 public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
 
        private boolean isThis;
+       private boolean alreadyWarnedAboutDEoW = false;
        private ExactAnnotationTypePattern annotationTypePattern;
        private ShadowMunger munger;
        
@@ -87,6 +88,10 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
                annotationTypePattern = (ExactAnnotationTypePattern) annotationTypePattern.resolveBindings(scope,bindings,true);
                // must be either a Var, or an annotation type pattern
                // if annotationType does not have runtime retention, this is an error
+               if (annotationTypePattern.annotationType == null) {
+                       // it's a formal with a binding error
+                       return;
+               }
                ResolvedTypeX rAnnotationType = (ResolvedTypeX) annotationTypePattern.annotationType;
                if (!(rAnnotationType.isAnnotationWithRuntimeRetention())) {
                    IMessage m = MessageUtil.error(
@@ -111,14 +116,19 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
        protected Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) {
                if (isDeclare(bindings.getEnclosingAdvice())) {
                          // Enforce rule about which designators are supported in declare
-                         inAspect.getWorld().showMessage(IMessage.ERROR,
-                                       WeaverMessages.format(WeaverMessages.THIS_OR_TARGET_IN_DECLARE,isThis?"this":"target"),
-                                       bindings.getEnclosingAdvice().getSourceLocation(), null);
+                         if (!alreadyWarnedAboutDEoW) {
+                                 inAspect.getWorld().showMessage(IMessage.ERROR,
+                                               WeaverMessages.format(WeaverMessages.THIS_OR_TARGET_IN_DECLARE,isThis?"this":"target"),
+                                               bindings.getEnclosingAdvice().getSourceLocation(), null);
+                                 alreadyWarnedAboutDEoW = true;
+                         }
                          return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                }
 
                ExactAnnotationTypePattern newType = (ExactAnnotationTypePattern) annotationTypePattern.remapAdviceFormals(bindings);           
-               Pointcut ret = new ThisOrTargetAnnotationPointcut(isThis, newType, bindings.getEnclosingAdvice());
+               ThisOrTargetAnnotationPointcut ret = 
+                       new ThisOrTargetAnnotationPointcut(isThis, newType, bindings.getEnclosingAdvice());
+               ret.alreadyWarnedAboutDEoW = alreadyWarnedAboutDEoW;
         ret.copyLocationFrom(this);
         return ret;
        }
index 2fe41c63cec3e82efef690503be3df2ab49107bb..c51d7008b7682cefd316eb505e8d15980829cf0b 100644 (file)
@@ -75,10 +75,8 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut {
                        return FuzzyBoolean.NO;
                }
 
-               toMatchAgainst = TypeX.forName(rMember.getSignature()).resolve(shadow.getIWorld());
-
                annotationTypePattern.resolve(shadow.getIWorld());
-               return annotationTypePattern.matches(toMatchAgainst);
+               return annotationTypePattern.matches(rMember);
        }