From 51aedc9a20c3c571f01bbfd79ca357759e008479 Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 31 Jan 2005 13:59:04 +0000 Subject: [PATCH] Updates for annotation binding. Support for static methods !! --- .../ajdt/internal/compiler/lookup/EclipseSourceType.java | 1 + weaver/src/org/aspectj/weaver/bcel/BcelShadow.java | 9 +++++---- .../aspectj/weaver/bcel/KindedAnnotationAccessVar.java | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java index 659f92fc9..aac3ae533 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java @@ -233,6 +233,7 @@ public class EclipseSourceType extends ResolvedTypeX.ConcreteName { public boolean hasAnnotation(TypeX ofType) { Annotation[] as = declaration.annotations; + if (as == null) return false; for (int i = 0; i < as.length; i++) { Annotation annotation = as[i]; String tname = CharOperation.charToString(annotation.resolvedType.constantPoolName()); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index 142ac4d9a..bcc0fd05d 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -1309,7 +1309,7 @@ public class BcelShadow extends Shadow { // !!! Refactor these once all shadow kinds added - there is lots of commonality if (getKind() == Shadow.MethodCall) { - ResolvedMember rm[] = this.getTargetType().getDeclaredMethods(world); + ResolvedMember rm[] = getSignature().getDeclaringType().getDeclaredMethods(world); ResolvedMember found = null; String searchString = getSignature().getName()+getSignature().getParameterSignature(); for (int i = 0; i < rm.length; i++) { @@ -1321,11 +1321,12 @@ public class BcelShadow extends Shadow { 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())); + kindedAnnotationVars.put(typeX, + new KindedAnnotationAccessVar(typeX.resolve(world),getSignature().getDeclaringType(),getSignature())); } } if (getKind() == Shadow.MethodExecution) { - ResolvedMember rm[] = this.getTargetType().getDeclaredMethods(world); + ResolvedMember rm[] = getSignature().getDeclaringType().getDeclaredMethods(world); ResolvedMember found = null; String searchString = getSignature().getName()+getSignature().getParameterSignature(); for (int i = 0; i < rm.length; i++) { @@ -1337,7 +1338,7 @@ public class BcelShadow extends Shadow { 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())); + kindedAnnotationVars.put(typeX,new KindedAnnotationAccessVar(typeX.resolve(world),getSignature().getDeclaringType(),getSignature())); } } // if (getKind() == Shadow.FieldSet) { diff --git a/weaver/src/org/aspectj/weaver/bcel/KindedAnnotationAccessVar.java b/weaver/src/org/aspectj/weaver/bcel/KindedAnnotationAccessVar.java index d8902a32a..c86f7e328 100644 --- a/weaver/src/org/aspectj/weaver/bcel/KindedAnnotationAccessVar.java +++ b/weaver/src/org/aspectj/weaver/bcel/KindedAnnotationAccessVar.java @@ -33,7 +33,7 @@ public class KindedAnnotationAccessVar extends BcelVar { private Member stackField; private int index; - BcelVar target; + TypeX target; Member sig; // public KindedAnnotationAccessVar(ResolvedTypeX type, Member stackField, int index) { @@ -42,7 +42,7 @@ public class KindedAnnotationAccessVar extends BcelVar { // this.index = index; // } - public KindedAnnotationAccessVar(ResolvedTypeX type,BcelVar theTargetIsStoredHere,Member sig) { + public KindedAnnotationAccessVar(ResolvedTypeX type,TypeX theTargetIsStoredHere,Member sig) { super(type,0); target = theTargetIsStoredHere; this.sig = sig; @@ -94,7 +94,7 @@ public class KindedAnnotationAccessVar extends BcelVar { // Calls getClass // 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(fact.createInvoke("java/lang/Object","getClass",jlClass,new Type[]{},Constants.INVOKEVIRTUAL)); -- 2.39.5