diff options
author | aclement <aclement> | 2005-01-31 13:21:53 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-01-31 13:21:53 +0000 |
commit | 258675f5f4b3aeac9dce29937ed052e91dcdf8c5 (patch) | |
tree | 1b03aaf5aec67e7d79317054c661f957f8a22dd1 /weaver | |
parent | a6765ad6557805f7e1d34de27e6f5b4f5258e548 (diff) | |
download | aspectj-258675f5f4b3aeac9dce29937ed052e91dcdf8c5.tar.gz aspectj-258675f5f4b3aeac9dce29937ed052e91dcdf8c5.zip |
Annotation Binding: works for @target and @annotation (when combined with call/execution, others to follow..)
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelShadow.java | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index 3a738cd26..142ac4d9a 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -904,7 +904,11 @@ public class BcelShadow extends Shadow { throw new IllegalStateException("no target"); } initializeTargetAnnotationVars(); - return (Var) targetAnnotationVars.get(forAnnotationType); + Var v =(Var) targetAnnotationVars.get(forAnnotationType); + // Even if we can't find one, we have to return one as we might have this annotation at runtime + if (v==null) + v = new TypeAnnotationAccessVar(forAnnotationType.resolve(world),(BcelVar)getTargetVar()); + return v; } public Var getArgVar(int i) { initializeArgVars(); @@ -1278,6 +1282,11 @@ public class BcelShadow extends Shadow { targetAnnotationVars = thisAnnotationVars; } else { targetAnnotationVars = new HashMap(); + ResolvedTypeX[] rtx = this.getTargetType().resolve(world).getAnnotationTypes(); // what about annotations we havent gotten yet but we will get in subclasses? + for (int i = 0; i < rtx.length; i++) { + ResolvedTypeX typeX = rtx[i]; + targetAnnotationVars.put(typeX,new TypeAnnotationAccessVar(typeX,(BcelVar)getTargetVar())); + } // populate. } } @@ -1298,6 +1307,55 @@ public class BcelShadow extends Shadow { // Then create one BcelVar entry in the map for each annotation, keyed by // annotation type (TypeX). + // !!! Refactor these once all shadow kinds added - there is lots of commonality + if (getKind() == Shadow.MethodCall) { + ResolvedMember rm[] = this.getTargetType().getDeclaredMethods(world); + ResolvedMember found = null; + String searchString = getSignature().getName()+getSignature().getParameterSignature(); + for (int i = 0; i < rm.length; i++) { + ResolvedMember member = rm[i]; + if ((member.getName()+member.getParameterSignature()).equals(searchString)) { + found = member; + } + } + ResolvedTypeX[] anns = found.getAnnotationTypes(); + for (int i = 0; i < anns.length; i++) { + ResolvedTypeX typeX = anns[i]; + kindedAnnotationVars.put(typeX,new KindedAnnotationAccessVar(typeX.resolve(world),(BcelVar)getTargetVar(),getSignature())); + } + } + if (getKind() == Shadow.MethodExecution) { + ResolvedMember rm[] = this.getTargetType().getDeclaredMethods(world); + ResolvedMember found = null; + String searchString = getSignature().getName()+getSignature().getParameterSignature(); + for (int i = 0; i < rm.length; i++) { + ResolvedMember member = rm[i]; + if ((member.getName()+member.getParameterSignature()).equals(searchString)) { + found = member; + } + } + ResolvedTypeX[] anns = found.getAnnotationTypes(); + for (int i = 0; i < anns.length; i++) { + ResolvedTypeX typeX = anns[i]; + kindedAnnotationVars.put(typeX,new KindedAnnotationAccessVar(typeX.resolve(world),(BcelVar)getTargetVar(),getSignature())); + } + } +// if (getKind() == Shadow.FieldSet) { +// ResolvedMember rm[] = this.getTargetType().getDeclaredFields(world); +// ResolvedMember found = null; +// for (int i = 0; i < rm.length; i++) { +// ResolvedMember member = rm[i]; +// if ((member.getName()+member.getParameterSignature()).equals(getSignature().getName()+getSignature().getParameterSignature())) { +// found = member; +// } +// } +// ResolvedTypeX[] anns = found.getAnnotationTypes(); +// for (int i = 0; i < anns.length; i++) { +// ResolvedTypeX typeX = anns[i]; +// kindedAnnotationVars.put(typeX,new KindedAnnotationAccessVar(typeX.resolve(world),(BcelVar)getTargetVar(),getSignature())); +// } +// } + } public void initializeWithinAnnotationVars() { if (withinAnnotationVars != null) return; |