// 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;
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()));
+ }
}
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;
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();
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;
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();