aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-10-06 22:10:54 +0000
committeracolyer <acolyer>2005-10-06 22:10:54 +0000
commit75f50930796059524f6e3435037fd3bea69503d4 (patch)
tree0bb46b327c07f2f51363c3555726dab544c600a8
parent671e1194f70d2d092dd2df035cf423ff0470a719 (diff)
downloadaspectj-75f50930796059524f6e3435037fd3bea69503d4.tar.gz
aspectj-75f50930796059524f6e3435037fd3bea69503d4.zip
fixes for generic abstract aspects
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java15
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java4
-rw-r--r--weaver/src/org/aspectj/weaver/Advice.java18
-rw-r--r--weaver/src/org/aspectj/weaver/Checker.java17
-rw-r--r--weaver/src/org/aspectj/weaver/CrosscuttingMembers.java2
-rw-r--r--weaver/src/org/aspectj/weaver/ReferenceType.java25
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java5
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedType.java22
-rw-r--r--weaver/src/org/aspectj/weaver/ShadowMunger.java3
-rw-r--r--weaver/src/org/aspectj/weaver/TypeVariable.java49
-rw-r--r--weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java22
-rw-r--r--weaver/src/org/aspectj/weaver/UnresolvedType.java7
-rw-r--r--weaver/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java35
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java9
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java13
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java5
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/DeclareAnnotation.java7
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java2
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java14
19 files changed, 249 insertions, 25 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
index e8b7bbc17..a9776e410 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
@@ -47,6 +47,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TagBits;
@@ -671,16 +672,22 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_DECLARE_ANNOTATIONS, sourceType.sourceName);
// Get the annotation specified in the declare
- TypeBinding tb = factory.makeTypeBinding(decA.getAspect());
+ UnresolvedType aspectType = decA.getAspect();
+ if (aspectType instanceof ReferenceType) {
+ ReferenceType rt = (ReferenceType) aspectType;
+ if (rt.isParameterizedType() || rt.isRawType()) {
+ aspectType = rt.getGenericType();
+ }
+ }
+ TypeBinding tb = factory.makeTypeBinding(aspectType);
- SourceTypeBinding stb = null;
// TODO asc determine if there really is a problem here (see comment below)
// ClassCastException here means we probably have either a parameterized type or a raw type, we need the
// commented out code to get it to work ... currently uncommented because I've not seen a case where its
// required yet ...
- stb = (SourceTypeBinding)tb;
- MethodBinding[] mbs = stb.getMethods(decA.getAnnotationMethod().toCharArray());
+ SourceTypeBinding stb = (SourceTypeBinding)tb;
+ MethodBinding[] mbs = stb.getMethods(decA.getAnnotationMethod().toCharArray());
long abits = mbs[0].getAnnotationTagBits(); // ensure resolved
TypeDeclaration typeDecl = ((SourceTypeBinding)mbs[0].declaringClass).scope.referenceContext;
AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(mbs[0]);
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
index 4eb290647..ac65d16ec 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
@@ -196,7 +196,9 @@ public class EclipseFactory {
}
// first piece of generics support!
if (binding instanceof TypeVariableBinding) {
- return fromTypeVariableBinding((TypeVariableBinding)binding);
+ TypeVariableBinding tb = (TypeVariableBinding) binding;
+ UnresolvedTypeVariableReferenceType utvrt = (UnresolvedTypeVariableReferenceType) fromTypeVariableBinding(tb);
+ return utvrt;
}
// handle arrays since the component type may need special treatment too...
diff --git a/weaver/src/org/aspectj/weaver/Advice.java b/weaver/src/org/aspectj/weaver/Advice.java
index 989b56501..704c76088 100644
--- a/weaver/src/org/aspectj/weaver/Advice.java
+++ b/weaver/src/org/aspectj/weaver/Advice.java
@@ -39,6 +39,9 @@ public abstract class Advice extends ShadowMunger {
protected TypePattern exceptionType; // just for Softener kind
+ // if we are parameterized, these type may be different to the advice signature types
+ protected UnresolvedType[] bindingParameterTypes;
+
protected List/*Lint.Kind*/ suppressedLintKinds = null; // based on annotations on this advice
public static Advice makeCflowEntry(World world, Pointcut entry, boolean isBelow, Member stackField, int nFreeVars, List innerCflowEntries, ResolvedType inAspect){
@@ -94,6 +97,11 @@ public abstract class Advice extends ShadowMunger {
this.attribute = attribute;
this.kind = attribute.getKind(); // alias
this.signature = signature;
+ if (signature != null) {
+ this.bindingParameterTypes = signature.getParameterTypes();
+ } else {
+ this.bindingParameterTypes = new UnresolvedType[0];
+ }
}
@@ -202,6 +210,11 @@ public abstract class Advice extends ShadowMunger {
return signature;
}
+ // only called as part of parameterization....
+ public void setSignature(Member signature) {
+ this.signature = signature;
+ }
+
public boolean hasExtraParameter() {
return (getExtraParameterFlags() & ExtraArgument) != 0;
}
@@ -214,6 +227,10 @@ public abstract class Advice extends ShadowMunger {
return countOnes(getExtraParameterFlags() & ParameterMask);
}
+ public UnresolvedType[] getBindingParameterTypes() { return this.bindingParameterTypes; }
+
+ public void setBindingParameterTypes(UnresolvedType[] types) { this.bindingParameterTypes = types; }
+
public static int countOnes(int bits) {
int ret = 0;
while (bits != 0) {
@@ -283,6 +300,7 @@ public abstract class Advice extends ShadowMunger {
Advice munger = world.createAdviceMunger(attribute, p, signature);
munger.concreteAspect = fromType;
+ munger.bindingParameterTypes = this.bindingParameterTypes;
//System.err.println("concretizing here " + p + " with clause " + clause);
return munger;
}
diff --git a/weaver/src/org/aspectj/weaver/Checker.java b/weaver/src/org/aspectj/weaver/Checker.java
index 4b035b171..c064c2610 100644
--- a/weaver/src/org/aspectj/weaver/Checker.java
+++ b/weaver/src/org/aspectj/weaver/Checker.java
@@ -29,7 +29,11 @@ public class Checker extends ShadowMunger {
super(deow.getPointcut(), deow.getStart(), deow.getEnd(), deow.getSourceContext());
this.msg = deow.getMessage();
this.isError = deow.isError();
- }
+ }
+
+ private Checker(Pointcut pc, int start, int end, ISourceContext context) {
+ super(pc,start,end,context);
+ }
public ShadowMunger concretize(ResolvedType fromType, World world, PerClause clause) {
pointcut = pointcut.concretize(fromType, getDeclaringType(), 0, this);
@@ -43,6 +47,17 @@ public class Checker extends ShadowMunger {
public void implementOn(Shadow shadow) {
throw new RuntimeException("illegal state");
}
+
+ public ShadowMunger parameterizeWith(Map typeVariableMap) {
+ Checker ret = new Checker(
+ getPointcut().parameterizeWith(typeVariableMap),
+ getStart(),
+ getEnd(),
+ this.sourceContext);
+ ret.msg = this.msg;
+ ret.isError = this.isError;
+ return ret;
+ }
public boolean match(Shadow shadow, World world) {
if (super.match(shadow, world)) {
diff --git a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java
index 3e74251b3..39f94f852 100644
--- a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java
+++ b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java
@@ -131,7 +131,7 @@ public class CrosscuttingMembers {
} else if (declare instanceof DeclareAnnotation) {
// FIXME asc perf Possible Improvement. Investigate why this is called twice in a weave ?
DeclareAnnotation da = (DeclareAnnotation)declare;
- da.setAspect(this.inAspect);
+ if (da.getAspect() == null) da.setAspect(this.inAspect);
if (da.isDeclareAtType()) {
declareAnnotationsOnType.add(da);
} else if (da.isDeclareAtField()) {
diff --git a/weaver/src/org/aspectj/weaver/ReferenceType.java b/weaver/src/org/aspectj/weaver/ReferenceType.java
index 9bf17a4aa..42b6bc2f7 100644
--- a/weaver/src/org/aspectj/weaver/ReferenceType.java
+++ b/weaver/src/org/aspectj/weaver/ReferenceType.java
@@ -430,10 +430,10 @@ public class ReferenceType extends ResolvedType {
protected Collection getDeclares() {
if (parameterizedDeclares != null) return parameterizedDeclares;
Collection declares = null;
- if (isParameterizedType()) {
+ if (ajMembersNeedParameterization()) {
Collection genericDeclares = delegate.getDeclares();
parameterizedDeclares = new ArrayList();
- Map parameterizationMap = getMemberParameterizationMap();
+ Map parameterizationMap = getAjMemberParameterizationMap();
for (Iterator iter = genericDeclares.iterator(); iter.hasNext();) {
Declare declareStatement = (Declare) iter.next();
parameterizedDeclares.add(declareStatement.parameterizeWith(parameterizationMap));
@@ -449,6 +449,21 @@ public class ReferenceType extends ResolvedType {
return declares;
}
+ private boolean ajMembersNeedParameterization() {
+ if (isParameterizedType()) return true;
+ if (getSuperclass() != null) return ((ReferenceType)getSuperclass()).ajMembersNeedParameterization();
+ return false;
+ }
+
+ private Map getAjMemberParameterizationMap() {
+ Map myMap = getMemberParameterizationMap();
+ if (myMap.size() == 0) {
+ // might extend a parameterized aspect that we also need to consider...
+ if (getSuperclass() != null) return ((ReferenceType)getSuperclass()).getAjMemberParameterizationMap();
+ }
+ return myMap;
+ }
+
protected Collection getTypeMungers() { return delegate.getTypeMungers(); }
protected Collection getPrivilegedAccesses() { return delegate.getPrivilegedAccesses(); }
@@ -459,7 +474,11 @@ public class ReferenceType extends ResolvedType {
}
public ResolvedType getSuperclass() {
- return delegate.getSuperclass();
+ ResolvedType ret = delegate.getSuperclass();
+ if (this.isParameterizedType() && ret.isParameterizedType()) {
+ ret = ret.parameterize(getMemberParameterizationMap()).resolve(getWorld());
+ }
+ return ret;
}
diff --git a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java
index c54ca4fd2..ff01be4b0 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java
@@ -299,6 +299,11 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
return (ResolvedType[])annotationTypes.toArray(new ResolvedType[]{});
}
+ public AnnotationX[] getAnnotations() {
+ if (backingGenericMember != null) return backingGenericMember.getAnnotations();
+ return super.getAnnotations();
+ }
+
public void setAnnotationTypes(UnresolvedType[] annotationtypes) {
if (annotationTypes == null) annotationTypes = new HashSet();
for (int i = 0; i < annotationtypes.length; i++) {
diff --git a/weaver/src/org/aspectj/weaver/ResolvedType.java b/weaver/src/org/aspectj/weaver/ResolvedType.java
index 75b0f84f3..5fb3ca9f3 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedType.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedType.java
@@ -635,7 +635,27 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
ShadowMunger munger = methods[i].getAssociatedShadowMunger();
if (munger != null) {
if (this.isParameterizedType()) {
- munger.setPointcut(munger.getPointcut().parameterizeWith(typeVariableMap));
+ //munger.setPointcut(munger.getPointcut().parameterizeWith(typeVariableMap));
+ munger = munger.parameterizeWith(typeVariableMap);
+ if (munger instanceof Advice) {
+ Advice advice = (Advice) munger;
+ // update to use the parameterized signature...
+ UnresolvedType[] ptypes = methods[i].getGenericParameterTypes() ;
+ UnresolvedType[] newPTypes = new UnresolvedType[ptypes.length];
+ for (int j = 0; j < ptypes.length; j++) {
+ if (ptypes[j] instanceof TypeVariableReferenceType) {
+ TypeVariableReferenceType tvrt = (TypeVariableReferenceType) ptypes[j];
+ if (typeVariableMap.containsKey(tvrt.getTypeVariable().getName())) {
+ newPTypes[j] = (UnresolvedType) typeVariableMap.get(tvrt.getTypeVariable().getName());
+ } else {
+ newPTypes[j] = ptypes[j];
+ }
+ } else {
+ newPTypes[j] = ptypes[j];
+ }
+ }
+ advice.setBindingParameterTypes(newPTypes);
+ }
}
munger.setDeclaringType(this);
l.add(munger);
diff --git a/weaver/src/org/aspectj/weaver/ShadowMunger.java b/weaver/src/org/aspectj/weaver/ShadowMunger.java
index 0d7e74925..3ff34bd8d 100644
--- a/weaver/src/org/aspectj/weaver/ShadowMunger.java
+++ b/weaver/src/org/aspectj/weaver/ShadowMunger.java
@@ -14,6 +14,7 @@
package org.aspectj.weaver;
import java.util.Collection;
+import java.util.Map;
import org.aspectj.asm.AsmManager;
import org.aspectj.bridge.ISourceLocation;
@@ -63,6 +64,8 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
return pointcut.match(shadow).maybeTrue();
}
+ public abstract ShadowMunger parameterizeWith(Map typeVariableMap);
+
public int fallbackCompareTo(Object other) {
return toString().compareTo(toString());
}
diff --git a/weaver/src/org/aspectj/weaver/TypeVariable.java b/weaver/src/org/aspectj/weaver/TypeVariable.java
index f450d8b76..9718179ab 100644
--- a/weaver/src/org/aspectj/weaver/TypeVariable.java
+++ b/weaver/src/org/aspectj/weaver/TypeVariable.java
@@ -42,7 +42,8 @@ public class TypeVariable {
/**
* What kind of element declared this type variable?
*/
- private int declaringElementKind = TYPE;
+ private int declaringElementKind = UNKNOWN;
+ public static final int UNKNOWN = -1;
public static final int METHOD = 1;
public static final int TYPE = 2;
private TypeVariableDeclaringElement declaringElement;
@@ -109,6 +110,47 @@ public class TypeVariable {
if (beingResolved) { return; } // avoid spiral of death
beingResolved = true;
if (isResolved) return;
+
+ TypeVariable resolvedTVar = null;
+
+ if (declaringElement != null) {
+ // resolve by finding the real type var that we refer to...
+ if (declaringElementKind == TYPE) {
+ UnresolvedType declaring = (UnresolvedType) declaringElement;
+ ReferenceType rd = (ReferenceType) declaring.resolve(inSomeWorld);
+ TypeVariable[] tVars = rd.getTypeVariables();
+ for (int i = 0; i < tVars.length; i++) {
+ if (tVars[i].getName().equals(getName())) {
+ resolvedTVar = tVars[i];
+ break;
+ }
+ }
+ } else {
+ // look for type variable on method...
+ ResolvedMember declaring = (ResolvedMember) declaringElement;
+ UnresolvedType[] tvrts = declaring.getTypeVariables();
+ for (int i = 0; i < tvrts.length; i++) {
+ if (tvrts[i].isTypeVariableReference()) {
+ TypeVariableReferenceType tvrt = (TypeVariableReferenceType) tvrts[i].resolve(inSomeWorld);
+ TypeVariable tv = tvrt.getTypeVariable();
+ if (tv.getName().equals(getName())) resolvedTVar = tv;
+ }
+ }
+ }
+
+ if (resolvedTVar == null) {
+ // well, this is bad... we didn't find the type variable on the member
+ // could be a separate compilation issue...
+ // should issue message, this is a workaround to get us going...
+ resolvedTVar = this;
+ }
+ } else {
+ resolvedTVar = this;
+ }
+
+ upperBound = resolvedTVar.upperBound;
+ lowerBound = resolvedTVar.lowerBound;
+ additionalInterfaceBounds = resolvedTVar.additionalInterfaceBounds;
upperBound = upperBound.resolve(inSomeWorld);
if (lowerBound != null) lowerBound = lowerBound.resolve(inSomeWorld);
@@ -258,6 +300,11 @@ public class TypeVariable {
public void setDeclaringElement(TypeVariableDeclaringElement element) {
this.declaringElement = element;
+ if (element instanceof UnresolvedType) {
+ this.declaringElementKind = TYPE;
+ } else {
+ this.declaringElementKind = METHOD;
+ }
}
public TypeVariableDeclaringElement getDeclaringElement() {
diff --git a/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java b/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
index ed340836a..f5e5e3306 100644
--- a/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
+++ b/weaver/src/org/aspectj/weaver/TypeVariableReferenceType.java
@@ -11,6 +11,9 @@
* ******************************************************************/
package org.aspectj.weaver;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
/**
* Represents a type variable in a type or generic method declaration
*/
@@ -69,7 +72,8 @@ public class TypeVariableReferenceType extends BoundedReferenceType implements T
public boolean isGenericWildcard() {
return false;
}
- //public ResolvedType resolve(World world) {
+
+ //public ResolvedType resolve(World world) {
// return super.resolve(world);
//}
@@ -97,4 +101,20 @@ public class TypeVariableReferenceType extends BoundedReferenceType implements T
sb.append(";");
return sb.toString();
}
+
+ public void write(DataOutputStream s) throws IOException {
+ super.write(s);
+ TypeVariableDeclaringElement tvde = typeVariable.getDeclaringElement();
+ if (tvde == null) {
+ s.writeInt(TypeVariable.UNKNOWN);
+ } else {
+ s.writeInt(typeVariable.getDeclaringElementKind());
+ if (typeVariable.getDeclaringElementKind() == TypeVariable.TYPE) {
+ ((UnresolvedType)tvde).write(s);
+ } else if (typeVariable.getDeclaringElementKind() == TypeVariable.METHOD){
+ // it's a method
+ ((ResolvedMember)tvde).write(s);
+ }
+ }
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/UnresolvedType.java b/weaver/src/org/aspectj/weaver/UnresolvedType.java
index f6c8804ba..e40867c8a 100644
--- a/weaver/src/org/aspectj/weaver/UnresolvedType.java
+++ b/weaver/src/org/aspectj/weaver/UnresolvedType.java
@@ -778,7 +778,12 @@ public class UnresolvedType implements TypeVariableDeclaringElement {
if (sig.equals(MISSING_NAME)) {
return ResolvedType.MISSING;
} else {
- return UnresolvedType.forSignature(sig);
+ UnresolvedType ret = UnresolvedType.forSignature(sig);
+ // ugh, this is horrid, we shouldn't know about this subclass.
+ if (ret instanceof UnresolvedTypeVariableReferenceType) {
+ UnresolvedTypeVariableReferenceType.readDeclaringElement(s, (UnresolvedTypeVariableReferenceType)ret);
+ }
+ return ret;
}
}
diff --git a/weaver/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java b/weaver/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java
index cf8494ea4..75eaa9710 100644
--- a/weaver/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java
+++ b/weaver/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java
@@ -11,6 +11,10 @@
* ******************************************************************/
package org.aspectj.weaver;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
/**
* @author colyer
* Represents a type variable encountered in the Eclipse Source world,
@@ -32,7 +36,7 @@ public class UnresolvedTypeVariableReferenceType extends UnresolvedType implemen
// only used when resolving circular refs...
public void setTypeVariable(TypeVariable aTypeVariable) {
- this.signature = aTypeVariable.getUpperBound().getSignature();
+ this.signature = "T" + aTypeVariable.getName() + ";"; //aTypeVariable.getUpperBound().getSignature();
this.typeVariable = aTypeVariable;
}
@@ -64,5 +68,34 @@ public class UnresolvedTypeVariableReferenceType extends UnresolvedType implemen
return "T" + typeVariable.getName() + ";";
}
}
+
+ public void write(DataOutputStream s) throws IOException {
+ super.write(s);
+ TypeVariableDeclaringElement tvde = typeVariable.getDeclaringElement();
+ if (tvde == null) {
+ s.writeInt(TypeVariable.UNKNOWN);
+ } else {
+ s.writeInt(typeVariable.getDeclaringElementKind());
+ if (typeVariable.getDeclaringElementKind() == TypeVariable.TYPE) {
+ ((UnresolvedType)tvde).write(s);
+ } else if (typeVariable.getDeclaringElementKind() == TypeVariable.METHOD){
+ // it's a method
+ ((ResolvedMember)tvde).write(s);
+ }
+ }
+ }
+
+ public static void readDeclaringElement(DataInputStream s, UnresolvedTypeVariableReferenceType utv)
+ throws IOException {
+ int kind = s.readInt();
+ utv.typeVariable.setDeclaringElementKind(kind);
+ if (kind == TypeVariable.TYPE) {
+ utv.typeVariable.setDeclaringElement(UnresolvedType.read(s));
+ } else if (kind == TypeVariable.METHOD) {
+ // it's a method
+ ResolvedMember rm = ResolvedMemberImpl.readResolvedMember(new VersionedDataInputStream(s),null);
+ utv.typeVariable.setDeclaringElement(rm);
+ }
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
index 0c119c09e..f349e55c5 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
@@ -17,6 +17,7 @@ package org.aspectj.weaver.bcel;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Map;
import org.aspectj.apache.bcel.generic.InstructionFactory;
import org.aspectj.apache.bcel.generic.InstructionHandle;
@@ -85,6 +86,12 @@ public class BcelAdvice extends Advice {
return ret;
}
+ public ShadowMunger parameterizeWith(Map typeVariableMap) {
+ Pointcut pc = getPointcut().parameterizeWith(typeVariableMap);
+ BcelAdvice ret = new BcelAdvice(this.attribute,pc,this.signature,this.concreteAspect);
+ return ret;
+ }
+
public boolean match(Shadow shadow, World world) {
suppressLintWarnings(world);
boolean ret = super.match(shadow, world);
@@ -441,7 +448,7 @@ public class BcelAdvice extends Advice {
}
}
} else {
- UnresolvedType desiredTy = getSignature().getParameterTypes()[i];
+ UnresolvedType desiredTy = getBindingParameterTypes()[i];
v.appendLoadAndConvert(il, fact, desiredTy.resolve(world));
}
}
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
index 05dc3fd14..fae1d10b7 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
@@ -1658,11 +1658,19 @@ class BcelClassWeaver implements IClassWeaver {
} else {
ResolvedMember realthing = AjcMemberMaker.interMethodDispatcher(rm,memberHostType);
ResolvedMember resolvedDooberry = world.resolve(realthing);
+ // AMC temp guard for M4
+ if (resolvedDooberry == null) {
+ throw new UnsupportedOperationException("Known limitation in M4 - can't find ITD members when type variable is used as an argument and has upper bound specified");
+ }
annotations = resolvedDooberry.getAnnotationTypes();
}
} else if (rm.getKind()==Member.CONSTRUCTOR) {
ResolvedMember realThing = AjcMemberMaker.postIntroducedConstructor(memberHostType.resolve(world),rm.getDeclaringType(),rm.getParameterTypes());
ResolvedMember resolvedDooberry = world.resolve(realThing);
+ // AMC temp guard for M4
+ if (resolvedDooberry == null) {
+ throw new UnsupportedOperationException("Known limitation in M4 - can't find ITD members when type variable is used as an argument and has upper bound specified");
+ }
annotations = resolvedDooberry.getAnnotationTypes();
}
if (annotations == null)
@@ -1670,7 +1678,10 @@ class BcelClassWeaver implements IClassWeaver {
mapToAnnotations.put(rm,annotations);
}
rm.setAnnotationTypes(annotations);
- } catch (Throwable t) {
+ }
+ catch (UnsupportedOperationException ex) {
+ throw ex;
+ } catch (Throwable t) {
//FIXME asc remove this catch after more testing has confirmed the above stuff is OK
throw new BCException("Unexpectedly went bang when searching for annotations on "+rm,t);
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java
index 0ff5b7841..7afd93fbe 100644
--- a/weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java
@@ -83,7 +83,10 @@ public class BindingTypePattern extends ExactTypePattern implements BindingPatte
}
public TypePattern parameterizeWith(Map typeVariableMap) {
- return this;
+ ExactTypePattern superParameterized = (ExactTypePattern) super.parameterizeWith(typeVariableMap);
+ BindingTypePattern ret = new BindingTypePattern(superParameterized.getExactType(),this.formalIndex,this.isVarArgs);
+ ret.copyLocationFrom(this);
+ return ret;
}
public String toString() {
diff --git a/weaver/src/org/aspectj/weaver/patterns/DeclareAnnotation.java b/weaver/src/org/aspectj/weaver/patterns/DeclareAnnotation.java
index 9234ea8ce..5210b1a91 100644
--- a/weaver/src/org/aspectj/weaver/patterns/DeclareAnnotation.java
+++ b/weaver/src/org/aspectj/weaver/patterns/DeclareAnnotation.java
@@ -112,15 +112,20 @@ public class DeclareAnnotation extends Declare {
if (sigPattern != null) {
sigPattern = sigPattern.resolveBindings(scope,Bindings.NONE);
}
+ this.containingAspect = scope.getEnclosingType();
}
public Declare parameterizeWith(Map typeVariableBindingMap) {
- Declare ret;
+ DeclareAnnotation ret;
if (this.kind == AT_TYPE) {
ret = new DeclareAnnotation(kind,this.typePattern.parameterizeWith(typeVariableBindingMap));
} else {
ret = new DeclareAnnotation(kind, this.sigPattern.parameterizeWith(typeVariableBindingMap));
}
+ ret.annotationMethod = this.annotationMethod;
+ ret.annotationString = this.annotationString;
+ ret.containingAspect = this.containingAspect;
+ ret.annotation = this.annotation;
ret.copyLocationFrom(this);
return ret;
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java b/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java
index e60ff8297..0c401c504 100644
--- a/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java
+++ b/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java
@@ -96,7 +96,7 @@ public class DeclarePrecedence extends Declare {
if (exactType == ResolvedType.MISSING) continue;
// Cannot do a dec prec specifying a non-aspect types unless suffixed with a '+'
- if (!exactType.isAspect() && !pi.isIncludeSubtypes()) {
+ if (!exactType.isAspect() && !pi.isIncludeSubtypes() && !exactType.isTypeVariableReference()) {
scope.getWorld().showMessage(IMessage.ERROR,
WeaverMessages.format(WeaverMessages.CLASSES_IN_PRECEDENCE,exactType.getName()),
pi.getSourceLocation(),null);
diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
index 2cea93d52..647090eeb 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
@@ -531,12 +531,16 @@ public class WildTypePattern extends TypePattern {
typeParameters.parameterizeWith(typeVariableMap)
);
ret.annotationPattern = this.annotationPattern.parameterizeWith(typeVariableMap);
- ret.additionalInterfaceBounds = new TypePattern[additionalInterfaceBounds.length];
- for (int i = 0; i < additionalInterfaceBounds.length; i++) {
- ret.additionalInterfaceBounds[i] = additionalInterfaceBounds[i].parameterizeWith(typeVariableMap);
+ if (additionalInterfaceBounds == null) {
+ ret.additionalInterfaceBounds = null;
+ } else {
+ ret.additionalInterfaceBounds = new TypePattern[additionalInterfaceBounds.length];
+ for (int i = 0; i < additionalInterfaceBounds.length; i++) {
+ ret.additionalInterfaceBounds[i] = additionalInterfaceBounds[i].parameterizeWith(typeVariableMap);
+ }
}
- ret.upperBound = upperBound.parameterizeWith(typeVariableMap);
- ret.lowerBound = lowerBound.parameterizeWith(typeVariableMap);
+ ret.upperBound = upperBound != null ? upperBound.parameterizeWith(typeVariableMap) : null;
+ ret.lowerBound = lowerBound != null ? lowerBound.parameterizeWith(typeVariableMap) : null;
ret.isGeneric = isGeneric;
ret.knownMatches = knownMatches;
ret.importedPrefixes = importedPrefixes;