From: acolyer Date: Fri, 10 Dec 2004 13:21:38 +0000 (+0000) Subject: @within, @withincode fixes X-Git-Tag: Root_AspectJ5_Development~150 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0485c3b5b128171d8a53c956e6d9561429cbcb7b;p=aspectj.git @within, @withincode fixes --- diff --git a/weaver/src/org/aspectj/weaver/ResolvedMember.java b/weaver/src/org/aspectj/weaver/ResolvedMember.java index 138f12f5c..90b8b59e9 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedMember.java +++ b/weaver/src/org/aspectj/weaver/ResolvedMember.java @@ -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 diff --git a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java index f763bfafc..946cdc99c 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java @@ -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; } diff --git a/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java index 2fe41c63c..c51d7008b 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java @@ -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); }