]> source.dussan.org Git - aspectj.git/commitdiff
more testing, @args support
authoracolyer <acolyer>
Thu, 9 Dec 2004 22:14:57 +0000 (22:14 +0000)
committeracolyer <acolyer>
Thu, 9 Dec 2004 22:14:57 +0000 (22:14 +0000)
15 files changed:
weaver/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java
weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/Pointcut.java
weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java
weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java

index af9511b1a532e0afcf938ef66f58082e27b3d608..47ec35969c1d6423049e36492ad59691a680bc6c 100644 (file)
@@ -16,6 +16,7 @@ import java.io.IOException;
 import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.AnnotatedElement;
 import org.aspectj.weaver.ISourceContext;
+import org.aspectj.weaver.World;
 
 /**
  * @author colyer
@@ -38,6 +39,11 @@ public class AndAnnotationTypePattern extends AnnotationTypePattern {
                return left.matches(annotated).and(right.matches(annotated));
        }
 
+       public void resolve(World world) {
+               left.resolve(world);
+               right.resolve(world);
+       }
+       
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings, boolean)
         */
index 140e83f42c7221e8b68c99c1a96eeb93fd1dc0ff..daca99502043b3e9aefe40ff9b97aa02c27f29c6 100644 (file)
@@ -14,8 +14,11 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.List;
 
+import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.IntMap;
+import org.aspectj.weaver.ResolvedTypeX;
+import org.aspectj.weaver.World;
 
 /**
  * @author colyer
@@ -49,6 +52,44 @@ public class AnnotationPatternList extends PatternNode {
        public AnnotationPatternList(List l) {
                this((AnnotationTypePattern[]) l.toArray(new AnnotationTypePattern[l.size()]));
        }
+
+       public void resolve(World inWorld) {
+               for (int i = 0; i < typePatterns.length; i++) {
+                       typePatterns[i].resolve(inWorld);
+               }
+       }
+       
+       public FuzzyBoolean matches(ResolvedTypeX[] someArgs) {
+               // do some quick length tests first
+               int numArgsMatchedByEllipsis = (someArgs.length + ellipsisCount) - typePatterns.length;
+               if (numArgsMatchedByEllipsis < 0) return FuzzyBoolean.NO;
+               if ((numArgsMatchedByEllipsis > 0) && (ellipsisCount == 0)) {
+                       return FuzzyBoolean.NO;
+               }
+               // now work through the args and the patterns, skipping at ellipsis
+       FuzzyBoolean ret = FuzzyBoolean.YES;
+       int argsIndex = 0;
+       for (int i = 0; i < typePatterns.length; i++) {
+                       if (typePatterns[i] == AnnotationTypePattern.ELLIPSIS) {
+                               // match ellipsisMatchCount args
+                               argsIndex += numArgsMatchedByEllipsis;
+                       } else if (typePatterns[i] == AnnotationTypePattern.ANY) {
+                               argsIndex++;
+                       } else {
+                               // match the argument type at argsIndex with the ExactAnnotationTypePattern
+                               // we know it is exact because nothing else is allowed in args
+                               ExactAnnotationTypePattern ap = (ExactAnnotationTypePattern)typePatterns[i];
+                               FuzzyBoolean matches = ap.matches(someArgs[argsIndex]);
+                               if (matches == FuzzyBoolean.NO) {
+                                       return FuzzyBoolean.NO;
+                               } else {
+                                       argsIndex++;
+                                       ret = ret.and(matches);
+                               }
+                       }
+               }       
+       return ret;
+       }
        
        public int size() { return typePatterns.length; }
        
index b6c549c455de51d80797148a671dc2a35c753ae1..a2325e9d39d8314091fe402c82fd9f2b68edde6d 100644 (file)
@@ -72,7 +72,7 @@ public class AnnotationPointcut extends NameBindingPointcut {
         */
        public FuzzyBoolean fastMatch(FastMatchInfo info) {
                if (info.getKind() == Shadow.StaticInitialization) {
-                       return annotationTypePattern.matches(info.getType());
+                       return annotationTypePattern.fastMatches(info.getType());
                } else {
                        return FuzzyBoolean.MAYBE;
                }
@@ -103,6 +103,7 @@ public class AnnotationPointcut extends NameBindingPointcut {
                        toMatchAgainst = rMember;
                }
                
+               annotationTypePattern.resolve(shadow.getIWorld());
                return annotationTypePattern.matches(toMatchAgainst);
        }
        
index 60edc3f3736e6af5a0a48384afbaf756c5202a57..1a4a34d18d93f3c9875c862ed3f4ae927f2ec1d6 100644 (file)
@@ -18,6 +18,7 @@ import org.aspectj.weaver.AnnotatedElement;
 import org.aspectj.weaver.BCException;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.IntMap;
+import org.aspectj.weaver.World;
 
 public abstract class AnnotationTypePattern extends PatternNode {
 
@@ -34,10 +35,16 @@ public abstract class AnnotationTypePattern extends PatternNode {
        
        public abstract FuzzyBoolean matches(AnnotatedElement annotated);
        
+       public FuzzyBoolean fastMatches(AnnotatedElement annotated) {
+               return FuzzyBoolean.MAYBE;
+       }
+       
        public AnnotationTypePattern remapAdviceFormals(IntMap bindings) {
                return this;
        }
        
+       public abstract void resolve(World world);
+       
        /**
         * This can modify in place, or return a new TypePattern if the type changes.
         */
@@ -84,6 +91,9 @@ class AnyAnnotationTypePattern extends AnnotationTypePattern {
                s.writeByte(AnnotationTypePattern.ANY_KEY);
        }
        
+       public void resolve(World world) {
+       }
+       
        public String toString() { return "@ANY"; }
 }
 
@@ -96,6 +106,9 @@ class EllipsisAnnotationTypePattern extends AnnotationTypePattern {
        public void write(DataOutputStream s) throws IOException {
                s.writeByte(AnnotationTypePattern.ELLIPSIS_KEY);
        }
-       
+
+       public void resolve(World world) {
+       }
+
        public String toString() { return ".."; }
 }
\ No newline at end of file
index cbf21bec81c75892e45761a525a2322c66e3f99f..66d771c14e77a4149f25adafa2c2d0798337b0d5 100644 (file)
@@ -9,13 +9,21 @@
  * ******************************************************************/
 package org.aspectj.weaver.patterns;
 
+import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.bridge.Message;
 import org.aspectj.util.FuzzyBoolean;
+import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.IntMap;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.Shadow;
+import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
+import org.aspectj.weaver.ast.Literal;
 import org.aspectj.weaver.ast.Test;
 
 /**
@@ -27,6 +35,7 @@ import org.aspectj.weaver.ast.Test;
 public class ArgsAnnotationPointcut extends NameBindingPointcut {
 
        private AnnotationPatternList arguments;
+       
        /**
         * 
         */
@@ -34,29 +43,33 @@ public class ArgsAnnotationPointcut extends NameBindingPointcut {
                super();
                this.arguments = arguments;
        }
-
+               
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.Pointcut#fastMatch(org.aspectj.weaver.patterns.FastMatchInfo)
         */
        public FuzzyBoolean fastMatch(FastMatchInfo info) {
-               // TODO Auto-generated method stub
-               return null;
+               return FuzzyBoolean.MAYBE;
        }
 
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.Pointcut#match(org.aspectj.weaver.Shadow)
         */
        public FuzzyBoolean match(Shadow shadow) {
-               // TODO Auto-generated method stub
-               return null;
+               arguments.resolve(shadow.getIWorld());
+               FuzzyBoolean ret =
+                       arguments.matches(shadow.getIWorld().resolve(shadow.getArgTypes()));
+               return ret;
        }
 
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.Pointcut#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings)
         */
        protected void resolveBindings(IScope scope, Bindings bindings) {
-               // TODO Auto-generated method stub
-
+               arguments.resolveBindings(scope, bindings, true);
+               if (arguments.ellipsisCount > 1) {
+                       scope.message(IMessage.ERROR, this,
+                                       "uses more than one .. in args (compiler limitation)");
+               }
        }
 
        /* (non-Javadoc)
@@ -64,33 +77,100 @@ public class ArgsAnnotationPointcut extends NameBindingPointcut {
         */
        protected void resolveBindingsFromRTTI() {
                // TODO Auto-generated method stub
-
        }
 
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.Pointcut#concretize1(org.aspectj.weaver.ResolvedTypeX, org.aspectj.weaver.IntMap)
         */
        protected Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) {
-               // TODO Auto-generated method stub
-               return null;
+               if (isDeclare(bindings.getEnclosingAdvice())) {
+                         // Enforce rule about which designators are supported in declare
+                         inAspect.getWorld().showMessage(IMessage.ERROR,
+                                       WeaverMessages.format(WeaverMessages.ARGS_IN_DECLARE),
+                                       bindings.getEnclosingAdvice().getSourceLocation(), null);
+                         return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
+               }
+               AnnotationPatternList list = arguments.resolveReferences(bindings);
+               return new ArgsAnnotationPointcut(list);
        }
 
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.Pointcut#findResidue(org.aspectj.weaver.Shadow, org.aspectj.weaver.patterns.ExposedState)
         */
        public Test findResidue(Shadow shadow, ExposedState state) {
-               // TODO Auto-generated method stub
-               return null;
+               int len = shadow.getArgCount();
+       
+               // do some quick length tests first
+               int numArgsMatchedByEllipsis = (len + arguments.ellipsisCount) - arguments.size();
+               if (numArgsMatchedByEllipsis < 0) return Literal.FALSE;  // should never happen
+               if ((numArgsMatchedByEllipsis > 0) && (arguments.ellipsisCount == 0)) {
+                       return Literal.FALSE; // should never happen
+               }
+               // now work through the args and the patterns, skipping at ellipsis
+       Test ret = Literal.TRUE;
+       int argsIndex = 0;
+       for (int i = 0; i < arguments.size(); i++) {
+                       if (arguments.get(i) == AnnotationTypePattern.ELLIPSIS) {
+                               // match ellipsisMatchCount args
+                               argsIndex += numArgsMatchedByEllipsis;
+                       } else if (arguments.get(i) == AnnotationTypePattern.ANY) {
+                               argsIndex++;
+                       } else {
+                               // match the argument type at argsIndex with the ExactAnnotationTypePattern
+                               // we know it is exact because nothing else is allowed in args
+                               ExactAnnotationTypePattern ap = (ExactAnnotationTypePattern)arguments.get(i);
+                               TypeX argType = shadow.getArgType(i);
+                               ResolvedTypeX rArgType = argType.resolve(shadow.getIWorld());
+                               if (rArgType == ResolvedTypeX.MISSING) {
+                         IMessage msg = new Message(
+                           WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_ARG_TYPE,argType.getName()),
+                           "",IMessage.ERROR,shadow.getSourceLocation(),null,new ISourceLocation[]{getSourceLocation()});
+                   }
+                               if (ap.matches(rArgType).alwaysTrue()) {
+                                       continue;
+                               } else {
+                                       // we need a test...
+                                       // TODO: binding
+                                       ResolvedTypeX rAnnType = ap.annotationType.resolve(shadow.getIWorld());
+                                       ret = Test.makeAnd(ret,Test.makeHasAnnotation(shadow.getArgVar(i),rAnnType));
+                               }                               
+                       }
+               }       
+       return ret;
        }
 
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream)
         */
        public void write(DataOutputStream s) throws IOException {
-               // TODO Auto-generated method stub
-
+               s.writeByte(Pointcut.ATARGS);
+               arguments.write(s);
+               writeLocation(s);
+       }
+       
+       public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException {
+               AnnotationPatternList annotationPatternList = AnnotationPatternList.read(s,context);
+               ArgsAnnotationPointcut ret = new ArgsAnnotationPointcut(annotationPatternList);
+               ret.readLocation(context, s);
+               return ret;
        }
 
+       /* (non-Javadoc)
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       public boolean equals(Object obj) {
+               if (!(obj instanceof ArgsAnnotationPointcut)) return false;
+               ArgsAnnotationPointcut other = (ArgsAnnotationPointcut) obj;
+               return other.arguments.equals(arguments);
+       }
+       
+       /* (non-Javadoc)
+        * @see java.lang.Object#hashCode()
+        */
+       public int hashCode() {
+               return 17 + 37*arguments.hashCode();
+       }
+       
        /* (non-Javadoc)
      * @see java.lang.Object#toString()
      */
index d6b63205274238ef85a6406e2f9c03a246b5bbea..a140e91493670592b719e7a6bd05bc098c190601 100644 (file)
@@ -38,14 +38,14 @@ public class BindingAnnotationTypePattern extends ExactAnnotationTypePattern imp
                this(binding.getType(),binding.getIndex());
        }
        
-       public AnnotationTypePattern resolve(World world) {
+       public void resolveBinding(World world) {
            // For 1.5.0 M1
                IMessage lim = MessageUtil.error("Binding not supported in @pcds (1.5.0 M1 limitation): " +
                        getSourceLocation());
                world.getMessageHandler().handleMessage(lim);
            // End of 1.5.0 M1
            
-               if (resolved) return this;
+               if (resolved) return;
                resolved = true;
                annotationType = annotationType.resolve(world);
                if (!annotationType.isAnnotation(world)) {
@@ -66,7 +66,6 @@ public class BindingAnnotationTypePattern extends ExactAnnotationTypePattern imp
                    // TO DO... get the retention policy annotation, and check the value is 
                    // RetentionPolicy.RUNTIME;
                }
-               return this;
        }
        
        
index b44c93e2db6db372c540a132642bbc2c6972a4e5..51ac632c679610986843691c5e685c8e4ed97967 100644 (file)
@@ -22,6 +22,7 @@ import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.TypeX;
 import org.aspectj.weaver.WeaverMessages;
+import org.aspectj.weaver.World;
 
 /**
  * Matches an annotation of a given type
@@ -48,12 +49,41 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern {
                // will be turned into BindingAnnotationTypePattern during resolution
        }
        
+       public FuzzyBoolean fastMatches(AnnotatedElement annotated) {
+               if (annotated.hasAnnotation(annotationType)) {
+                       return FuzzyBoolean.YES;
+               } else {
+                       // could be inherited, but we don't know that until we are 
+                       // resolved, and we're not yet...
+                       return FuzzyBoolean.MAYBE;
+               }
+       }
+       
        public FuzzyBoolean matches(AnnotatedElement annotated) {
-               return (annotated.hasAnnotation(annotationType) ?
-                                  FuzzyBoolean.YES : FuzzyBoolean.NO);
+               boolean checkSupers = false;
+               if (annotationType.hasAnnotation(TypeX.AT_INHERITED)) {
+                       if (annotated instanceof ResolvedTypeX) {
+                               checkSupers = true;
+                       }
+               }
+               
+               if (annotated.hasAnnotation(annotationType)) {
+                       return FuzzyBoolean.YES;
+               } else if (checkSupers) {
+                       ResolvedTypeX toMatchAgainst = ((ResolvedTypeX) annotated).getSuperclass();
+                       while (toMatchAgainst != null) {
+                               if (toMatchAgainst.hasAnnotation(annotationType)) return FuzzyBoolean.YES;
+                               toMatchAgainst = toMatchAgainst.getSuperclass();
+                       }
+               } 
+               return FuzzyBoolean.NO;
        }
 
        
+       public void resolve(World world) {
+               annotationType = annotationType.resolve(world);
+       }
+
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings, boolean)
         */
@@ -77,7 +107,7 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern {
                                BindingAnnotationTypePattern binding = new BindingAnnotationTypePattern(formalBinding);
                                binding.copyLocationFrom(this);
                                bindings.register(binding, scope);
-                               binding.resolve(scope.getWorld());
+                               binding.resolveBinding(scope.getWorld());
                                
                                return binding;
                        } else {
index 8e3679e537a64bc77918b56cd7aed5446b3ed109..869bbf43cd4128c7af66d880c8abec056b3bb7f2 100644 (file)
@@ -16,6 +16,7 @@ import java.io.IOException;
 import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.AnnotatedElement;
 import org.aspectj.weaver.ISourceContext;
+import org.aspectj.weaver.World;
 
 public class NotAnnotationTypePattern extends AnnotationTypePattern {
 
@@ -32,6 +33,13 @@ public class NotAnnotationTypePattern extends AnnotationTypePattern {
        public FuzzyBoolean matches(AnnotatedElement annotated) {
                return negatedPattern.matches(annotated).not();
        }
+       
+       /* (non-Javadoc)
+        * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolve(org.aspectj.weaver.World)
+        */
+       public void resolve(World world) {
+               negatedPattern.resolve(world);
+       }
 
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings, boolean)
index 0f23f6b2cbe859097c9ea21f14e2ea7b4b4e0edf..7c7c12fcafd8107f2484ca6f6dc8bb5d4ccfe07a 100644 (file)
@@ -16,6 +16,7 @@ import java.io.IOException;
 import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.AnnotatedElement;
 import org.aspectj.weaver.ISourceContext;
+import org.aspectj.weaver.World;
 
 public class OrAnnotationTypePattern extends AnnotationTypePattern {
 
@@ -31,6 +32,11 @@ public class OrAnnotationTypePattern extends AnnotationTypePattern {
        public FuzzyBoolean matches(AnnotatedElement annotated) {
                return left.matches(annotated).or(right.matches(annotated));
        }
+       
+       public void resolve(World world) {
+               left.resolve(world);
+               right.resolve(world);
+       }
 
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings, boolean)
index afd01ce86846f22fb91ba823e6f7fedebe16cac2..0cc96ef3d3674cc75f6969edf38cf6587b73e084 100644 (file)
@@ -128,8 +128,9 @@ public abstract class Pointcut extends PatternNode implements PointcutExpression
        public static final byte ATWITHIN = 17;
        public static final byte ATWITHINCODE = 18;
        public static final byte ATTHIS_OR_TARGET = 19;
+       public static final byte ATARGS = 20;
        
-       public static final byte NONE = 20;
+       public static final byte NONE = 40;
 
        public byte getPointcutKind() { return pointcutKind; }
 
@@ -249,6 +250,7 @@ public abstract class Pointcut extends PatternNode implements PointcutExpression
                        case ATWITHIN: ret = WithinAnnotationPointcut.read(s, context); break;
                        case ATWITHINCODE: ret = WithinCodeAnnotationPointcut.read(s, context); break;
                        case ATTHIS_OR_TARGET: ret = ThisOrTargetAnnotationPointcut.read(s, context); break;
+                       case ATARGS: ret = ArgsAnnotationPointcut.read(s,context); break;
                        case NONE: ret = makeMatchesNothing(RESOLVED); break;
                        default:
                                throw new BCException("unknown kind: " + kind);
index c34a3ee7fe794c7025012406f2295c21974fa09d..7c51135f7503fddf36c9cdef8665c573f0470057 100644 (file)
@@ -130,6 +130,7 @@ public class SignaturePattern extends PatternNode {
                        world.getLint().unresolvableMember.signal(member.toString(), getSourceLocation());
                        return false;
          }
+         annotationPattern.resolve(world);
          return annotationPattern.matches(rMember).alwaysTrue();
        }
        
index 516e3668120569774490c1a19527a8642da6dfa0..f763bfafc8f68ee251d74feb8806acb7dd2d39b3 100644 (file)
@@ -67,25 +67,15 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
         */
        public FuzzyBoolean match(Shadow shadow) {
                if (!couldMatch(shadow)) return FuzzyBoolean.NO;
-               TypeX annotationType = annotationTypePattern.annotationType;
-               annotationType = annotationType.resolve(shadow.getIWorld());
-               if (annotationType.hasAnnotation(TypeX.AT_INHERITED)) {
-                   // we can attempt to match now
-                   ResolvedTypeX toMatchAgainst = 
-                       (isThis ? shadow.getThisType() : shadow.getTargetType() ).resolve(shadow.getIWorld());
-                   if (toMatchAgainst.hasAnnotation(annotationType)) {
-                       return FuzzyBoolean.YES;
-                   } else {
-                       ResolvedTypeX superC = toMatchAgainst;
-                       while ((superC = superC.getSuperclass()) != null) {
-                               if (superC.hasAnnotation(annotationType)) return FuzzyBoolean.YES;
-//                             if (superC.getName().equals("java.lang.Object")) return FuzzyBoolean.NO;
-                       }
-                       return FuzzyBoolean.NO;
-                   }
-               } 
-           // else we can only do matching via a runtime test
-               return FuzzyBoolean.MAYBE;
+           ResolvedTypeX toMatchAgainst = 
+               (isThis ? shadow.getThisType() : shadow.getTargetType() ).resolve(shadow.getIWorld());
+           annotationTypePattern.resolve(shadow.getIWorld());
+           if (annotationTypePattern.matches(toMatchAgainst).alwaysTrue()) {
+               return FuzzyBoolean.YES;
+           } else {
+               // a subtype may match at runtime
+               return FuzzyBoolean.MAYBE;
+           }
        }
 
        public boolean isThis() { return isThis; }
@@ -119,6 +109,14 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
         * @see org.aspectj.weaver.patterns.Pointcut#concretize1(org.aspectj.weaver.ResolvedTypeX, org.aspectj.weaver.IntMap)
         */
        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);
+                         return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
+               }
+
                ExactAnnotationTypePattern newType = (ExactAnnotationTypePattern) annotationTypePattern.remapAdviceFormals(bindings);           
                Pointcut ret = new ThisOrTargetAnnotationPointcut(isThis, newType, bindings.getEnclosingAdvice());
         ret.copyLocationFrom(this);
index 4b19f24d35a12a416bd2191879bcb053d17ccf50..3cce9aca89e905837352a90f20eaa1b7e7c5d9c9 100644 (file)
@@ -21,6 +21,7 @@ import org.aspectj.weaver.BCException;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.WeaverMessages;
+import org.aspectj.weaver.World;
 
 /**
  * @author colyer
@@ -60,6 +61,13 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
                return FuzzyBoolean.NO;
        }
 
+       /* (non-Javadoc)
+        * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolve(org.aspectj.weaver.World)
+        */
+       public void resolve(World world) {
+               // nothing to do...
+       }
+       
        /**
         * This can modify in place, or return a new TypePattern if the type changes.
         */
index e5242d7d1781b46e88693aced70801fe022c395a..76bf81abee35fda4ee6c7a6e24712418e4dbd8b5 100644 (file)
@@ -56,7 +56,7 @@ public class WithinAnnotationPointcut extends NameBindingPointcut {
         * @see org.aspectj.weaver.patterns.Pointcut#fastMatch(org.aspectj.weaver.patterns.FastMatchInfo)
         */
        public FuzzyBoolean fastMatch(FastMatchInfo info) {
-           return annotationTypePattern.matches(info.getType());
+           return annotationTypePattern.fastMatches(info.getType());
        }
 
        /* (non-Javadoc)
@@ -71,6 +71,7 @@ public class WithinAnnotationPointcut extends NameBindingPointcut {
                                shadow.getSourceLocation(),true,new ISourceLocation[]{getSourceLocation()});
                        shadow.getIWorld().getMessageHandler().handleMessage(msg);
                }
+               annotationTypePattern.resolve(shadow.getIWorld());
                return annotationTypePattern.matches(enclosingType);
        }
 
index b2801171806c8916b9cbb3fe71cf7b4195a04299..2fe41c63cec3e82efef690503be3df2ab49107bb 100644 (file)
@@ -76,7 +76,8 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut {
                }
 
                toMatchAgainst = TypeX.forName(rMember.getSignature()).resolve(shadow.getIWorld());
-               
+
+               annotationTypePattern.resolve(shadow.getIWorld());
                return annotationTypePattern.matches(toMatchAgainst);
        }