Browse Source

Updates for annotation binding. Support for static methods !!

tags/Root_AspectJ5_Development
aclement 19 years ago
parent
commit
51aedc9a20

+ 1
- 0
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java View File

public boolean hasAnnotation(TypeX ofType) { public boolean hasAnnotation(TypeX ofType) {
Annotation[] as = declaration.annotations; Annotation[] as = declaration.annotations;
if (as == null) return false;
for (int i = 0; i < as.length; i++) { for (int i = 0; i < as.length; i++) {
Annotation annotation = as[i]; Annotation annotation = as[i];
String tname = CharOperation.charToString(annotation.resolvedType.constantPoolName()); String tname = CharOperation.charToString(annotation.resolvedType.constantPoolName());

+ 5
- 4
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java View File

// !!! Refactor these once all shadow kinds added - there is lots of commonality // !!! Refactor these once all shadow kinds added - there is lots of commonality
if (getKind() == Shadow.MethodCall) { if (getKind() == Shadow.MethodCall) {
ResolvedMember rm[] = this.getTargetType().getDeclaredMethods(world);
ResolvedMember rm[] = getSignature().getDeclaringType().getDeclaredMethods(world);
ResolvedMember found = null; ResolvedMember found = null;
String searchString = getSignature().getName()+getSignature().getParameterSignature(); String searchString = getSignature().getName()+getSignature().getParameterSignature();
for (int i = 0; i < rm.length; i++) { for (int i = 0; i < rm.length; i++) {
ResolvedTypeX[] anns = found.getAnnotationTypes(); ResolvedTypeX[] anns = found.getAnnotationTypes();
for (int i = 0; i < anns.length; i++) { for (int i = 0; i < anns.length; i++) {
ResolvedTypeX typeX = anns[i]; ResolvedTypeX typeX = anns[i];
kindedAnnotationVars.put(typeX,new KindedAnnotationAccessVar(typeX.resolve(world),(BcelVar)getTargetVar(),getSignature()));
kindedAnnotationVars.put(typeX,
new KindedAnnotationAccessVar(typeX.resolve(world),getSignature().getDeclaringType(),getSignature()));
} }
} }
if (getKind() == Shadow.MethodExecution) { if (getKind() == Shadow.MethodExecution) {
ResolvedMember rm[] = this.getTargetType().getDeclaredMethods(world);
ResolvedMember rm[] = getSignature().getDeclaringType().getDeclaredMethods(world);
ResolvedMember found = null; ResolvedMember found = null;
String searchString = getSignature().getName()+getSignature().getParameterSignature(); String searchString = getSignature().getName()+getSignature().getParameterSignature();
for (int i = 0; i < rm.length; i++) { for (int i = 0; i < rm.length; i++) {
ResolvedTypeX[] anns = found.getAnnotationTypes(); ResolvedTypeX[] anns = found.getAnnotationTypes();
for (int i = 0; i < anns.length; i++) { for (int i = 0; i < anns.length; i++) {
ResolvedTypeX typeX = anns[i]; ResolvedTypeX typeX = anns[i];
kindedAnnotationVars.put(typeX,new KindedAnnotationAccessVar(typeX.resolve(world),(BcelVar)getTargetVar(),getSignature()));
kindedAnnotationVars.put(typeX,new KindedAnnotationAccessVar(typeX.resolve(world),getSignature().getDeclaringType(),getSignature()));
} }
} }
// if (getKind() == Shadow.FieldSet) { // if (getKind() == Shadow.FieldSet) {

+ 3
- 3
weaver/src/org/aspectj/weaver/bcel/KindedAnnotationAccessVar.java View File



private Member stackField; private Member stackField;
private int index; private int index;
BcelVar target;
TypeX target;
Member sig; Member sig;


// public KindedAnnotationAccessVar(ResolvedTypeX type, Member stackField, int index) { // public KindedAnnotationAccessVar(ResolvedTypeX type, Member stackField, int index) {
// this.index = index; // this.index = index;
// } // }
public KindedAnnotationAccessVar(ResolvedTypeX type,BcelVar theTargetIsStoredHere,Member sig) {
public KindedAnnotationAccessVar(ResolvedTypeX type,TypeX theTargetIsStoredHere,Member sig) {
super(type,0); super(type,0);
target = theTargetIsStoredHere; target = theTargetIsStoredHere;
this.sig = sig; this.sig = sig;
// Calls getClass // Calls getClass
// System.err.println("What is the class of target? "+target.getType()); // System.err.println("What is the class of target? "+target.getType());
il.append(fact.createConstant(BcelWorld.makeBcelType(target.getType())));
il.append(fact.createConstant(BcelWorld.makeBcelType(target)));
// il.append(target.createLoad(fact)); // il.append(target.createLoad(fact));
// il.append(fact.createInvoke("java/lang/Object","getClass",jlClass,new Type[]{},Constants.INVOKEVIRTUAL)); // il.append(fact.createInvoke("java/lang/Object","getClass",jlClass,new Type[]{},Constants.INVOKEVIRTUAL));

Loading…
Cancel
Save