@@ -1316,7 +1316,7 @@ public class BcelShadow extends Shadow { | |||
// Then create one BcelVar entry in the map for each annotation, keyed by | |||
// annotation type (TypeX). | |||
// !!! PREAJ5FINAL Refactor these once all shadow kinds added - there is lots of commonality | |||
// FIXME Refactor these once all shadow kinds added - there is lots of commonality | |||
ResolvedTypeX[] annotations = null; | |||
TypeX relevantType = null; | |||
@@ -1412,12 +1412,28 @@ public class BcelShadow extends Shadow { | |||
public void initializeWithinAnnotationVars() { | |||
if (withinAnnotationVars != null) return; | |||
withinAnnotationVars = new HashMap(); | |||
// populate | |||
ResolvedTypeX[] annotations = getEnclosingType().getAnnotationTypes(); | |||
for (int i = 0; i < annotations.length; i++) { | |||
ResolvedTypeX ann = annotations[i]; | |||
Kind k = Shadow.StaticInitialization; | |||
withinAnnotationVars.put(ann,new KindedAnnotationAccessVar(k,ann,getEnclosingType(),null)); | |||
} | |||
} | |||
public void initializeWithinCodeAnnotationVars() { | |||
if (withincodeAnnotationVars != null) return; | |||
withincodeAnnotationVars = new HashMap(); | |||
// populate | |||
// For some shadow we are interested in annotations on the method containing that shadow. | |||
ResolvedTypeX[] annotations = getEnclosingMethod().getMemberView().getAnnotationTypes(); | |||
for (int i = 0; i < annotations.length; i++) { | |||
ResolvedTypeX ann = annotations[i]; | |||
Kind k = (getEnclosingMethod().getMemberView().getKind()==Member.CONSTRUCTOR? | |||
Shadow.ConstructorExecution:Shadow.MethodExecution); | |||
withincodeAnnotationVars.put(ann, | |||
new KindedAnnotationAccessVar(k,ann,getEnclosingType(),getEnclosingCodeSignature())); | |||
} | |||
} | |||
@@ -20,6 +20,7 @@ import org.aspectj.bridge.IMessage; | |||
import org.aspectj.bridge.ISourceLocation; | |||
import org.aspectj.bridge.Message; | |||
import org.aspectj.util.FuzzyBoolean; | |||
import org.aspectj.weaver.BCException; | |||
import org.aspectj.weaver.ISourceContext; | |||
import org.aspectj.weaver.IntMap; | |||
import org.aspectj.weaver.ResolvedTypeX; | |||
@@ -117,7 +118,14 @@ public class WithinAnnotationPointcut extends NameBindingPointcut { | |||
BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern)annotationTypePattern; | |||
TypeX annotationType = btp.annotationType; | |||
Var var = shadow.getWithinAnnotationVar(annotationType); | |||
if (var == null) return Literal.FALSE; | |||
// This should not happen, we shouldn't have gotten this far | |||
// if we weren't going to find the annotation | |||
if (var == null) | |||
throw new BCException("Impossible! annotation=["+annotationType+ | |||
"] shadow=["+shadow+" at "+shadow.getSourceLocation()+ | |||
"] pointcut is at ["+getSourceLocation()+"]"); | |||
// Check if we have already bound something to this formal | |||
if ((state.get(btp.getFormalIndex())!=null) &&(lastMatchedShadowId == shadow.shadowId)) { | |||
// ISourceLocation pcdSloc = getSourceLocation(); |
@@ -19,6 +19,7 @@ import java.util.Set; | |||
import org.aspectj.util.FuzzyBoolean; | |||
import org.aspectj.weaver.AnnotatedElement; | |||
import org.aspectj.weaver.BCException; | |||
import org.aspectj.weaver.ISourceContext; | |||
import org.aspectj.weaver.IntMap; | |||
import org.aspectj.weaver.Member; | |||
@@ -130,7 +131,14 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut { | |||
BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern)annotationTypePattern; | |||
TypeX annotationType = btp.annotationType; | |||
Var var = shadow.getWithinCodeAnnotationVar(annotationType); | |||
if (var == null) return Literal.FALSE; | |||
// This should not happen, we shouldn't have gotten this far | |||
// if we weren't going to find the annotation | |||
if (var == null) | |||
throw new BCException("Impossible! annotation=["+annotationType+ | |||
"] shadow=["+shadow+" at "+shadow.getSourceLocation()+ | |||
"] pointcut is at ["+getSourceLocation()+"]"); | |||
// Check if we have already bound something to this formal | |||
if ((state.get(btp.getFormalIndex())!=null) &&(lastMatchedShadowId == shadow.shadowId)) { | |||
// ISourceLocation pcdSloc = getSourceLocation(); |