summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-09-21 15:05:14 +0000
committeracolyer <acolyer>2005-09-21 15:05:14 +0000
commit5f93dd1b209827833813978a860dcf1a95b20197 (patch)
tree6149b5cb175474531e940c8994f3592914a4ea66
parenta39f595c0cdcddf8eac0b99e1918d0578f2dc501 (diff)
downloadaspectj-5f93dd1b209827833813978a860dcf1a95b20197.tar.gz
aspectj-5f93dd1b209827833813978a860dcf1a95b20197.zip
fix for annotation binding bug when target type in bytecode != declaring type (1.4)
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedType.java17
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelShadow.java56
2 files changed, 50 insertions, 23 deletions
diff --git a/weaver/src/org/aspectj/weaver/ResolvedType.java b/weaver/src/org/aspectj/weaver/ResolvedType.java
index bb42a7e3b..9d6a43f6a 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedType.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedType.java
@@ -918,6 +918,18 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
return ret;
}
+ public ResolvedMember lookupMemberWithSupersAndITDs(Member member) {
+ ResolvedMember ret = lookupMemberNoSupers(member);
+ if (ret != null) return ret;
+
+ ResolvedType supert = getSuperclass();
+ if (supert != null) {
+ ret = supert.lookupMemberNoSupers(member);
+ }
+
+ return ret;
+ }
+
/**
* as lookupMemberNoSupers, but does not include ITDs
* @param member
@@ -1442,6 +1454,11 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
return ret;
}
}
+
+// if (this.getSuperclass() != ResolvedType.OBJECT && this.getSuperclass() != null) {
+// return getSuperclass().lookupSyntheticMember(member);
+// }
+
return null;
}
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
index 60f47f0aa..c13b8df83 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
@@ -1350,12 +1350,16 @@ public class BcelShadow extends Shadow {
}
}
- protected Member getRelevantMember(Member relevantMember, ResolvedType relevantType){
- if (relevantMember != null){
- return relevantMember;
+ protected Member getRelevantMember(Member foundMember, Member relevantMember, ResolvedType relevantType){
+ if (foundMember != null){
+ return foundMember;
}
- relevantMember = getSignature().resolve(world);
+
+ foundMember = getSignature().resolve(world);
+ if (foundMember == null && relevantMember != null) {
+ foundMember = relevantType.lookupMemberWithSupersAndITDs(relevantMember);
+ }
// check the ITD'd dooberries
List mungers = relevantType.resolve(world).getInterTypeMungers();
@@ -1366,26 +1370,26 @@ public class BcelShadow extends Shadow {
ResolvedMember fakerm = typeMunger.getSignature();
if (fakerm.getName().equals(getSignature().getName()) &&
fakerm.getParameterSignature().equals(getSignature().getParameterSignature())){
- if (relevantMember.getKind()==ResolvedMember.CONSTRUCTOR){
- relevantMember = AjcMemberMaker.interConstructor(
+ if (foundMember.getKind()==ResolvedMember.CONSTRUCTOR){
+ foundMember = AjcMemberMaker.interConstructor(
relevantType,
- (ResolvedMember)relevantMember,
+ (ResolvedMember)foundMember,
typeMunger.getAspectType());
} else {
- relevantMember = AjcMemberMaker.interMethod((ResolvedMember)relevantMember,
+ foundMember = AjcMemberMaker.interMethod((ResolvedMember)foundMember,
typeMunger.getAspectType(), false);
}
// in the above.. what about if it's on an Interface? Can that happen?
// then the last arg of the above should be true
- return relevantMember;
+ return foundMember;
}
}
}
- return null;
+ return foundMember;
}
- protected ResolvedType [] getAnnotations(Member relevantMember, ResolvedType relevantType){
- if (relevantMember == null){
+ protected ResolvedType [] getAnnotations(Member foundMember, Member relevantMember, ResolvedType relevantType){
+ if (foundMember == null){
// check the ITD'd dooberries
List mungers = relevantType.resolve(world).getInterTypeMungers();
for (Iterator iter = mungers.iterator(); iter.hasNext();) {
@@ -1403,13 +1407,18 @@ public class BcelShadow extends Shadow {
if (fakerm.getName().equals(getSignature().getName()) &&
fakerm.getParameterSignature().equals(getSignature().getParameterSignature())) {
relevantType = typeMunger.getAspectType();
- relevantMember = rmm;
- return relevantMember.getAnnotationTypes();
+ foundMember = rmm;
+ return foundMember.getAnnotationTypes();
}
}
}
+ // didn't find in ITDs, look in supers
+ foundMember = relevantType.lookupMemberWithSupersAndITDs(relevantMember);
+ if (foundMember == null) {
+ throw new IllegalStateException("Couldn't find member " + relevantMember + " for type " + relevantType);
+ }
}
- return relevantMember.getAnnotationTypes();
+ return foundMember.getAnnotationTypes();
}
public void initializeKindedAnnotationVars() {
@@ -1429,10 +1438,10 @@ public class BcelShadow extends Shadow {
annotations = relevantType.resolve(world).getAnnotationTypes();
} else if (getKind() == Shadow.MethodCall || getKind() == Shadow.ConstructorCall) {
- relevantMember = findMethod2(relevantType.resolve(world).getDeclaredMethods(),getSignature());
-
- annotations = getAnnotations(relevantMember,relevantType);
- relevantMember = getRelevantMember(relevantMember,relevantType);
+ Member foundMember = findMethod2(relevantType.resolve(world).getDeclaredMethods(),getSignature());
+ annotations = getAnnotations(foundMember, relevantMember, relevantType);
+ relevantMember = getRelevantMember(foundMember,relevantMember,relevantType);
+ relevantType = relevantMember.getDeclaringType().resolve(world);
} else if (getKind() == Shadow.FieldSet || getKind() == Shadow.FieldGet) {
relevantMember = findField(relevantType.getDeclaredFields(),getSignature());
@@ -1459,11 +1468,12 @@ public class BcelShadow extends Shadow {
} else if (getKind() == Shadow.MethodExecution || getKind() == Shadow.ConstructorExecution ||
getKind() == Shadow.AdviceExecution) {
ResolvedMember rm[] = relevantType.getDeclaredMethods();
- relevantMember = findMethod2(relevantType.getDeclaredMethods(),getSignature());
-
- annotations = getAnnotations(relevantMember,relevantType);
- relevantMember = getRelevantMember(relevantMember,relevantType);
+ Member foundMember = findMethod2(relevantType.getDeclaredMethods(),getSignature());
+ annotations = getAnnotations(foundMember, relevantMember,relevantType);
+ relevantMember = foundMember;
+ relevantMember = getRelevantMember(foundMember, relevantMember,relevantType);
+
} else if (getKind() == Shadow.ExceptionHandler) {
relevantType = getSignature().getParameterTypes()[0].resolve(world);
annotations = relevantType.getAnnotationTypes();