summaryrefslogtreecommitdiffstats
path: root/weaver/src
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-10-05 20:59:26 +0000
committeracolyer <acolyer>2005-10-05 20:59:26 +0000
commit3459ad57fc5af1ec01a0af3235775dfc9086ae7c (patch)
tree9de62b9b7714fd1caaf19016122a9a42273d7155 /weaver/src
parentab6c7a562a887b70c6b5ad0ac644e7af58394aa3 (diff)
downloadaspectj-3459ad57fc5af1ec01a0af3235775dfc9086ae7c.tar.gz
aspectj-3459ad57fc5af1ec01a0af3235775dfc9086ae7c.zip
these changes prevent us from forgetting the interface bounds of a TypeVariableReferenceType, and from forgetting bindings when parameterizing bindingxxxtypepatterns in generic abstract aspects.
Diffstat (limited to 'weaver/src')
-rw-r--r--weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java30
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java28
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java5
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java13
4 files changed, 69 insertions, 7 deletions
diff --git a/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java b/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
index 356fc0f26..ed340836a 100644
--- a/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
+++ b/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
@@ -17,6 +17,7 @@ package org.aspectj.weaver;
public class TypeVariableReferenceType extends BoundedReferenceType implements TypeVariableReference {
private TypeVariable typeVariable;
+ private boolean resolvedIfBounds = false;
public TypeVariableReferenceType(
TypeVariable aTypeVariable,
@@ -37,15 +38,24 @@ public class TypeVariableReferenceType extends BoundedReferenceType implements T
return typeVariable.getLowerBound();
}
- public ReferenceType[] getAdditionalBounds() {
- if (additionalInterfaceBounds ==null && typeVariable.getAdditionalInterfaceBounds()!=null) {
+ private void setAdditionalInterfaceBoundsFromTypeVar() {
+ if (typeVariable.getAdditionalInterfaceBounds() == null) {
+ return;
+ } else {
UnresolvedType [] ifBounds = typeVariable.getAdditionalInterfaceBounds();
additionalInterfaceBounds = new ReferenceType[ifBounds.length];
for (int i = 0; i < ifBounds.length; i++) {
- additionalInterfaceBounds[i] = (ReferenceType) ifBounds[i];
+ additionalInterfaceBounds[i] = (ReferenceType) ifBounds[i].resolve(getWorld());
}
}
- return additionalInterfaceBounds;
+ }
+
+ public ReferenceType[] getAdditionalBounds() {
+ if (!resolvedIfBounds) {
+ setAdditionalInterfaceBoundsFromTypeVar();
+ resolvedIfBounds = true;
+ }
+ return super.getAdditionalBounds();
}
public TypeVariable getTypeVariable() {
@@ -63,6 +73,18 @@ public class TypeVariableReferenceType extends BoundedReferenceType implements T
// return super.resolve(world);
//}
+ public boolean isAnnotation() {
+ World world = ((ReferenceType)getUpperBound()).getWorld();
+ ResolvedType annotationType = ResolvedType.ANNOTATION.resolve(world);
+ if (getUpperBound() != null && ((ReferenceType)getUpperBound()).isAnnotation()) return true;
+ ReferenceType[] ifBounds = getAdditionalBounds();
+ for (int i = 0; i < ifBounds.length; i++) {
+ if (ifBounds[i].isAnnotation()) return true;
+ if (ifBounds[i] == annotationType) return true; // annotation itself does not have the annotation flag set in Java!
+ }
+ return false;
+ }
+
/**
* return the signature for a *REFERENCE* to a type variable, which is simply:
* Tname;
diff --git a/weaver/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java
index cf63694ca..70b410266 100644
--- a/weaver/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java
@@ -11,6 +11,7 @@ package org.aspectj.weaver.patterns;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.Map;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.MessageUtil;
@@ -18,6 +19,7 @@ import org.aspectj.weaver.BCException;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.IntMap;
import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.TypeVariableReference;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.WeaverMessages;
@@ -52,7 +54,12 @@ public class BindingAnnotationTypePattern extends ExactAnnotationTypePattern imp
world.getMessageHandler().handleMessage(m);
resolved = false;
}
- if (!resolvedAnnotationType.isAnnotationWithRuntimeRetention()) { // default is class visibility
+ if (annotationType.isTypeVariableReference()) return; // we'll deal with this next check when the type var is actually bound...
+ verifyRuntimeRetention(world, resolvedAnnotationType);
+ }
+
+ private void verifyRuntimeRetention(World world, ResolvedType resolvedAnnotationType) {
+ if (!resolvedAnnotationType.isAnnotationWithRuntimeRetention()) { // default is class visibility
// default is class visibility
IMessage m = MessageUtil.error(
WeaverMessages.format(WeaverMessages.BINDING_NON_RUNTIME_RETENTION_ANNOTATION,annotationType.getName()),
@@ -62,6 +69,25 @@ public class BindingAnnotationTypePattern extends ExactAnnotationTypePattern imp
}
}
+ public AnnotationTypePattern parameterizeWith(Map typeVariableMap) {
+ UnresolvedType newAnnotationType = annotationType;
+ if (annotationType.isTypeVariableReference()) {
+ TypeVariableReference t = (TypeVariableReference) annotationType;
+ String key = t.getTypeVariable().getName();
+ if (typeVariableMap.containsKey(key)) {
+ newAnnotationType = (UnresolvedType) typeVariableMap.get(key);
+ }
+ } else if (annotationType.isParameterizedType()) {
+ newAnnotationType = annotationType.parameterize(typeVariableMap);
+ }
+ BindingAnnotationTypePattern ret = new BindingAnnotationTypePattern(newAnnotationType,this.formalIndex);
+ if (newAnnotationType instanceof ResolvedType) {
+ ResolvedType rat = (ResolvedType) newAnnotationType;
+ verifyRuntimeRetention(rat.getWorld(),rat);
+ }
+ ret.copyLocationFrom(this);
+ return ret;
+ }
public int getFormalIndex() {
return formalIndex;
diff --git a/weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java
index 718eee9a1..0ff5b7841 100644
--- a/weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java
@@ -15,6 +15,7 @@ package org.aspectj.weaver.patterns;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.Map;
import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.ISourceContext;
@@ -80,6 +81,10 @@ public class BindingTypePattern extends ExactTypePattern implements BindingPatte
return new BindingTypePattern(type, newFormalIndex, isVarArgs);
}
}
+
+ public TypePattern parameterizeWith(Map typeVariableMap) {
+ return this;
+ }
public String toString() {
//Thread.currentThread().dumpStack();
diff --git a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
index b5526f9d8..2a0f0ef4e 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
@@ -80,6 +80,10 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
}
public Pointcut parameterizeWith(Map typeVariableMap) {
+ ExactAnnotationTypePattern newPattern = (ExactAnnotationTypePattern) this.annotationTypePattern.parameterizeWith(typeVariableMap);
+ if (newPattern.getAnnotationType() instanceof ResolvedType) {
+ verifyRuntimeRetention((ResolvedType)newPattern.getResolvedAnnotationType());
+ }
ThisOrTargetAnnotationPointcut ret = new ThisOrTargetAnnotationPointcut(isThis,(ExactAnnotationTypePattern)annotationTypePattern.parameterizeWith(typeVariableMap));
ret.copyLocationFrom(this);
return ret;
@@ -122,13 +126,18 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
return;
}
ResolvedType rAnnotationType = (ResolvedType) annotationTypePattern.annotationType;
+ if (rAnnotationType.isTypeVariableReference()) return; // we'll deal with this next check when the type var is actually bound...
+ verifyRuntimeRetention(rAnnotationType);
+
+ }
+
+ private void verifyRuntimeRetention(ResolvedType rAnnotationType) {
if (!(rAnnotationType.isAnnotationWithRuntimeRetention())) {
IMessage m = MessageUtil.error(
WeaverMessages.format(WeaverMessages.BINDING_NON_RUNTIME_RETENTION_ANNOTATION,rAnnotationType.getName()),
getSourceLocation());
- scope.getMessageHandler().handleMessage(m);
+ rAnnotationType.getWorld().getMessageHandler().handleMessage(m);
}
-
}
/* (non-Javadoc)