@@ -19,6 +19,7 @@ import org.aspectj.util.FuzzyBoolean; | |||
import org.aspectj.weaver.CompressingDataOutputStream; | |||
import org.aspectj.weaver.ISourceContext; | |||
import org.aspectj.weaver.ResolvedType; | |||
import org.aspectj.weaver.UnresolvedType; | |||
import org.aspectj.weaver.VersionedDataInputStream; | |||
import org.aspectj.weaver.World; | |||
@@ -41,33 +42,40 @@ public class AndTypePattern extends TypePattern { | |||
setLocation(left.getSourceContext(), left.getStart(), right.getEnd()); | |||
} | |||
@Override | |||
protected boolean couldEverMatchSameTypesAs(TypePattern other) { | |||
return true; // don't dive into ands yet.... | |||
} | |||
@Override | |||
public FuzzyBoolean matchesInstanceof(ResolvedType type) { | |||
return left.matchesInstanceof(type).and(right.matchesInstanceof(type)); | |||
} | |||
@Override | |||
protected boolean matchesExactly(ResolvedType type) { | |||
// ??? if these had side-effects, this sort-circuit could be a mistake | |||
return left.matchesExactly(type) && right.matchesExactly(type); | |||
} | |||
@Override | |||
protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) { | |||
return left.matchesExactly(type, annotatedType) && right.matchesExactly(type, annotatedType); | |||
} | |||
@Override | |||
public boolean matchesStatically(ResolvedType type) { | |||
return left.matchesStatically(type) && right.matchesStatically(type); | |||
} | |||
@Override | |||
public void setIsVarArgs(boolean isVarArgs) { | |||
this.isVarArgs = isVarArgs; | |||
left.setIsVarArgs(isVarArgs); | |||
right.setIsVarArgs(isVarArgs); | |||
} | |||
@Override | |||
public void setAnnotationTypePattern(AnnotationTypePattern annPatt) { | |||
if (annPatt == AnnotationTypePattern.ANY) { | |||
return; | |||
@@ -84,6 +92,7 @@ public class AndTypePattern extends TypePattern { | |||
} | |||
} | |||
@Override | |||
public void write(CompressingDataOutputStream s) throws IOException { | |||
s.writeByte(TypePattern.AND); | |||
left.write(s); | |||
@@ -100,6 +109,7 @@ public class AndTypePattern extends TypePattern { | |||
return ret; | |||
} | |||
@Override | |||
public TypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType) { | |||
if (requireExactType) { | |||
return notExactType(scope); | |||
@@ -108,8 +118,9 @@ public class AndTypePattern extends TypePattern { | |||
right = right.resolveBindings(scope, bindings, false, false); | |||
return this; | |||
} | |||
public TypePattern parameterizeWith(Map typeVariableMap, World w) { | |||
@Override | |||
public TypePattern parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) { | |||
TypePattern newLeft = left.parameterizeWith(typeVariableMap, w); | |||
TypePattern newRight = right.parameterizeWith(typeVariableMap, w); | |||
AndTypePattern ret = new AndTypePattern(newLeft, newRight); | |||
@@ -117,6 +128,7 @@ public class AndTypePattern extends TypePattern { | |||
return ret; | |||
} | |||
@Override | |||
public String toString() { | |||
StringBuffer buff = new StringBuffer(); | |||
if (annotationPattern != AnnotationTypePattern.ANY) { | |||
@@ -143,6 +155,7 @@ public class AndTypePattern extends TypePattern { | |||
return right; | |||
} | |||
@Override | |||
public boolean equals(Object obj) { | |||
if (!(obj instanceof AndTypePattern)) { | |||
return false; | |||
@@ -151,6 +164,7 @@ public class AndTypePattern extends TypePattern { | |||
return left.equals(atp.left) && right.equals(atp.right); | |||
} | |||
@Override | |||
public boolean isStarAnnotation() { | |||
return left.isStarAnnotation() && right.isStarAnnotation(); | |||
} | |||
@@ -160,6 +174,7 @@ public class AndTypePattern extends TypePattern { | |||
* | |||
* @see java.lang.Object#hashCode() | |||
*/ | |||
@Override | |||
public int hashCode() { | |||
int ret = 17; | |||
ret = ret + 37 * left.hashCode(); | |||
@@ -167,10 +182,12 @@ public class AndTypePattern extends TypePattern { | |||
return ret; | |||
} | |||
@Override | |||
public Object accept(PatternNodeVisitor visitor, Object data) { | |||
return visitor.visit(this, data); | |||
} | |||
@Override | |||
public Object traverse(PatternNodeVisitor visitor, Object data) { | |||
Object ret = accept(visitor, data); | |||
left.traverse(visitor, ret); |
@@ -82,11 +82,13 @@ public class AnnotationPointcut extends NameBindingPointcut { | |||
return annotationTypePattern; | |||
} | |||
@Override | |||
public int couldMatchKinds() { | |||
return Shadow.ALL_SHADOW_KINDS_BITS; | |||
} | |||
public Pointcut parameterizeWith(Map typeVariableMap, World w) { | |||
@Override | |||
public Pointcut parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) { | |||
AnnotationPointcut ret = new AnnotationPointcut((ExactAnnotationTypePattern) annotationTypePattern.parameterizeWith( | |||
typeVariableMap, w)); | |||
ret.copyLocationFrom(this); | |||
@@ -98,6 +100,7 @@ public class AnnotationPointcut extends NameBindingPointcut { | |||
* | |||
* @see org.aspectj.weaver.patterns.Pointcut#fastMatch(org.aspectj.weaver.patterns.FastMatchInfo) | |||
*/ | |||
@Override | |||
public FuzzyBoolean fastMatch(FastMatchInfo info) { | |||
if (info.getKind() == Shadow.StaticInitialization) { | |||
return annotationTypePattern.fastMatches(info.getType()); | |||
@@ -111,6 +114,7 @@ public class AnnotationPointcut extends NameBindingPointcut { | |||
* | |||
* @see org.aspectj.weaver.patterns.Pointcut#match(org.aspectj.weaver.Shadow) | |||
*/ | |||
@Override | |||
protected FuzzyBoolean matchInternal(Shadow shadow) { | |||
AnnotatedElement toMatchAgainst = null; | |||
Member member = shadow.getSignature(); | |||
@@ -173,6 +177,7 @@ public class AnnotationPointcut extends NameBindingPointcut { | |||
* @see org.aspectj.weaver.patterns.Pointcut#resolveBindings(org.aspectj.weaver.patterns.IScope, | |||
* org.aspectj.weaver.patterns.Bindings) | |||
*/ | |||
@Override | |||
protected void resolveBindings(IScope scope, Bindings bindings) { | |||
if (!scope.getWorld().isInJava5Mode()) { | |||
scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.ATANNOTATION_ONLY_SUPPORTED_AT_JAVA5_LEVEL), | |||
@@ -188,6 +193,7 @@ public class AnnotationPointcut extends NameBindingPointcut { | |||
* | |||
* @see org.aspectj.weaver.patterns.Pointcut#concretize1(org.aspectj.weaver.ResolvedType, org.aspectj.weaver.IntMap) | |||
*/ | |||
@Override | |||
protected Pointcut concretize1(ResolvedType inAspect, ResolvedType declaringType, IntMap bindings) { | |||
ExactAnnotationTypePattern newType = (ExactAnnotationTypePattern) annotationTypePattern.remapAdviceFormals(bindings); | |||
Pointcut ret = new AnnotationPointcut(newType, bindings.getEnclosingAdvice()); | |||
@@ -195,6 +201,7 @@ public class AnnotationPointcut extends NameBindingPointcut { | |||
return ret; | |||
} | |||
@Override | |||
protected Test findResidueInternal(Shadow shadow, ExposedState state) { | |||
if (annotationTypePattern instanceof BindingAnnotationFieldTypePattern) { | |||
if (shadow.getKind() != Shadow.MethodExecution) { | |||
@@ -254,6 +261,7 @@ public class AnnotationPointcut extends NameBindingPointcut { | |||
* | |||
* @see org.aspectj.weaver.patterns.NameBindingPointcut#getBindingAnnotationTypePatterns() | |||
*/ | |||
@Override | |||
public List<BindingPattern> getBindingAnnotationTypePatterns() { | |||
if (annotationTypePattern instanceof BindingPattern) { // BindingAnnotationTypePattern) { | |||
List<BindingPattern> l = new ArrayList<BindingPattern>(); | |||
@@ -269,6 +277,7 @@ public class AnnotationPointcut extends NameBindingPointcut { | |||
* | |||
* @see org.aspectj.weaver.patterns.NameBindingPointcut#getBindingTypePatterns() | |||
*/ | |||
@Override | |||
public List<BindingTypePattern> getBindingTypePatterns() { | |||
return Collections.emptyList(); | |||
} | |||
@@ -278,6 +287,7 @@ public class AnnotationPointcut extends NameBindingPointcut { | |||
* | |||
* @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream) | |||
*/ | |||
@Override | |||
public void write(CompressingDataOutputStream s) throws IOException { | |||
s.writeByte(Pointcut.ANNOTATION); | |||
annotationTypePattern.write(s); | |||
@@ -291,6 +301,7 @@ public class AnnotationPointcut extends NameBindingPointcut { | |||
return ret; | |||
} | |||
@Override | |||
public boolean equals(Object other) { | |||
if (!(other instanceof AnnotationPointcut)) { | |||
return false; | |||
@@ -299,6 +310,7 @@ public class AnnotationPointcut extends NameBindingPointcut { | |||
return o.annotationTypePattern.equals(this.annotationTypePattern); | |||
} | |||
@Override | |||
public int hashCode() { | |||
int result = 17; | |||
result = 37 * result + annotationTypePattern.hashCode(); | |||
@@ -314,10 +326,12 @@ public class AnnotationPointcut extends NameBindingPointcut { | |||
this.declarationText = buf.toString(); | |||
} | |||
@Override | |||
public String toString() { | |||
return this.declarationText; | |||
} | |||
@Override | |||
public Object accept(PatternNodeVisitor visitor, Object data) { | |||
return visitor.visit(this, data); | |||
} |
@@ -18,6 +18,7 @@ import org.aspectj.util.FuzzyBoolean; | |||
import org.aspectj.weaver.AnnotatedElement; | |||
import org.aspectj.weaver.CompressingDataOutputStream; | |||
import org.aspectj.weaver.ResolvedType; | |||
import org.aspectj.weaver.UnresolvedType; | |||
import org.aspectj.weaver.World; | |||
public class AnyAnnotationTypePattern extends AnnotationTypePattern { | |||
@@ -62,7 +63,7 @@ public class AnyAnnotationTypePattern extends AnnotationTypePattern { | |||
} | |||
@Override | |||
public AnnotationTypePattern parameterizeWith(Map arg0, World w) { | |||
public AnnotationTypePattern parameterizeWith(Map<String,UnresolvedType> arg0, World w) { | |||
return this; | |||
} | |||
@@ -17,6 +17,7 @@ import java.util.Map; | |||
import org.aspectj.util.FuzzyBoolean; | |||
import org.aspectj.weaver.CompressingDataOutputStream; | |||
import org.aspectj.weaver.ResolvedType; | |||
import org.aspectj.weaver.UnresolvedType; | |||
import org.aspectj.weaver.World; | |||
public class AnyTypePattern extends TypePattern { | |||
@@ -106,7 +107,7 @@ public class AnyTypePattern extends TypePattern { | |||
} | |||
@Override | |||
public TypePattern parameterizeWith(Map arg0, World w) { | |||
public TypePattern parameterizeWith(Map<String,UnresolvedType> arg0, World w) { | |||
return this; | |||
} | |||
} |
@@ -65,6 +65,7 @@ public class BindingAnnotationFieldTypePattern extends ExactAnnotationTypePatter | |||
} | |||
} | |||
@Override | |||
public AnnotationTypePattern parameterizeWith(Map typeVariableMap, World w) { | |||
throw new BCException("Parameterization not implemented for annotation field binding construct (compiler limitation)"); | |||
// UnresolvedType newAnnotationType = annotationType; | |||
@@ -86,10 +87,12 @@ public class BindingAnnotationFieldTypePattern extends ExactAnnotationTypePatter | |||
// return ret; | |||
} | |||
@Override | |||
public int getFormalIndex() { | |||
return formalIndex; | |||
} | |||
@Override | |||
public boolean equals(Object obj) { | |||
if (!(obj instanceof BindingAnnotationFieldTypePattern)) { | |||
return false; | |||
@@ -99,10 +102,12 @@ public class BindingAnnotationFieldTypePattern extends ExactAnnotationTypePatter | |||
&& (formalType.equals(btp.formalType)); | |||
} | |||
@Override | |||
public int hashCode() { | |||
return (annotationType.hashCode() * 37 + formalIndex * 37) + formalType.hashCode(); | |||
} | |||
@Override | |||
public AnnotationTypePattern remapAdviceFormals(IntMap bindings) { | |||
if (!bindings.hasKey(formalIndex)) { | |||
throw new BCException("Annotation field binding reference must be bound (compiler limitation)"); | |||
@@ -117,6 +122,7 @@ public class BindingAnnotationFieldTypePattern extends ExactAnnotationTypePatter | |||
} | |||
} | |||
@Override | |||
public void write(CompressingDataOutputStream s) throws IOException { | |||
s.writeByte(AnnotationTypePattern.BINDINGFIELD2); | |||
formalType.write(s); // the type of the field within the annotation | |||
@@ -141,6 +147,7 @@ public class BindingAnnotationFieldTypePattern extends ExactAnnotationTypePatter | |||
return ret; | |||
} | |||
@Override | |||
public FuzzyBoolean matches(AnnotatedElement annotated, ResolvedType[] parameterAnnotations) { | |||
// Inheritance irrelevant because @annotation(Anno(x)) only supported at method execution join points (compiler limitation) | |||
// boolean checkSupers = false; |
@@ -18,6 +18,7 @@ import java.util.Set; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.bridge.MessageUtil; | |||
import org.aspectj.util.FuzzyBoolean; | |||
import org.aspectj.weaver.AjAttribute.WeaverVersionInfo; | |||
import org.aspectj.weaver.AnnotatedElement; | |||
import org.aspectj.weaver.AnnotationAJ; | |||
import org.aspectj.weaver.BCException; | |||
@@ -31,7 +32,6 @@ import org.aspectj.weaver.UnresolvedType; | |||
import org.aspectj.weaver.VersionedDataInputStream; | |||
import org.aspectj.weaver.WeaverMessages; | |||
import org.aspectj.weaver.World; | |||
import org.aspectj.weaver.AjAttribute.WeaverVersionInfo; | |||
/** | |||
* Matches an annotation of a given type | |||
@@ -321,13 +321,13 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern { | |||
} | |||
@Override | |||
public AnnotationTypePattern parameterizeWith(Map typeVariableMap, World w) { | |||
public AnnotationTypePattern parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) { | |||
UnresolvedType newAnnotationType = annotationType; | |||
if (annotationType.isTypeVariableReference()) { | |||
TypeVariableReference t = (TypeVariableReference) annotationType; | |||
String key = t.getTypeVariable().getName(); | |||
if (typeVariableMap.containsKey(key)) { | |||
newAnnotationType = (UnresolvedType) typeVariableMap.get(key); | |||
newAnnotationType = typeVariableMap.get(key); | |||
} | |||
} else if (annotationType.isParameterizedType()) { | |||
newAnnotationType = annotationType.parameterize(typeVariableMap); |
@@ -457,7 +457,7 @@ public class KindedPointcut extends Pointcut { | |||
} | |||
@Override | |||
public Pointcut parameterizeWith(Map typeVariableMap, World w) { | |||
public Pointcut parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) { | |||
Pointcut ret = new KindedPointcut(kind, signature.parameterizeWith(typeVariableMap, w), munger); | |||
ret.copyLocationFrom(this); | |||
return ret; |
@@ -17,6 +17,7 @@ import java.util.Map; | |||
import org.aspectj.util.FuzzyBoolean; | |||
import org.aspectj.weaver.CompressingDataOutputStream; | |||
import org.aspectj.weaver.ResolvedType; | |||
import org.aspectj.weaver.UnresolvedType; | |||
import org.aspectj.weaver.World; | |||
public class NoTypePattern extends TypePattern { | |||
@@ -111,7 +112,7 @@ public class NoTypePattern extends TypePattern { | |||
} | |||
@Override | |||
public TypePattern parameterizeWith(Map arg0, World w) { | |||
public TypePattern parameterizeWith(Map<String,UnresolvedType> arg0, World w) { | |||
return this; | |||
} | |||
} |
@@ -21,6 +21,7 @@ import org.aspectj.weaver.ISourceContext; | |||
import org.aspectj.weaver.IntMap; | |||
import org.aspectj.weaver.ResolvedType; | |||
import org.aspectj.weaver.Shadow; | |||
import org.aspectj.weaver.UnresolvedType; | |||
import org.aspectj.weaver.VersionedDataInputStream; | |||
import org.aspectj.weaver.World; | |||
import org.aspectj.weaver.ast.Test; | |||
@@ -40,6 +41,7 @@ public class NotPointcut extends Pointcut { | |||
setLocation(pointcut.getSourceContext(), startPos, pointcut.getEnd()); | |||
} | |||
@Override | |||
public int couldMatchKinds() { | |||
return Shadow.ALL_SHADOW_KINDS_BITS; | |||
} | |||
@@ -48,19 +50,23 @@ public class NotPointcut extends Pointcut { | |||
return body; | |||
} | |||
@Override | |||
public FuzzyBoolean fastMatch(FastMatchInfo type) { | |||
return body.fastMatch(type).not(); | |||
} | |||
@Override | |||
protected FuzzyBoolean matchInternal(Shadow shadow) { | |||
return body.match(shadow).not(); | |||
} | |||
@Override | |||
public String toString() { | |||
return "!" + body.toString(); | |||
} | |||
@Override | |||
public boolean equals(Object other) { | |||
if (!(other instanceof NotPointcut)) { | |||
return false; | |||
@@ -69,10 +75,12 @@ public class NotPointcut extends Pointcut { | |||
return o.body.equals(body); | |||
} | |||
@Override | |||
public int hashCode() { | |||
return 37 * 23 + body.hashCode(); | |||
} | |||
@Override | |||
public void resolveBindings(IScope scope, Bindings bindings) { | |||
// Bindings old = bindings.copy(); | |||
@@ -85,6 +93,7 @@ public class NotPointcut extends Pointcut { | |||
} | |||
@Override | |||
public void write(CompressingDataOutputStream s) throws IOException { | |||
s.writeByte(Pointcut.NOT); | |||
body.write(s); | |||
@@ -97,26 +106,31 @@ public class NotPointcut extends Pointcut { | |||
return ret; | |||
} | |||
@Override | |||
protected Test findResidueInternal(Shadow shadow, ExposedState state) { | |||
return Test.makeNot(body.findResidue(shadow, state)); | |||
} | |||
@Override | |||
public Pointcut concretize1(ResolvedType inAspect, ResolvedType declaringType, IntMap bindings) { | |||
Pointcut ret = new NotPointcut(body.concretize(inAspect, declaringType, bindings)); | |||
ret.copyLocationFrom(this); | |||
return ret; | |||
} | |||
public Pointcut parameterizeWith(Map typeVariableMap, World w) { | |||
@Override | |||
public Pointcut parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) { | |||
Pointcut ret = new NotPointcut(body.parameterizeWith(typeVariableMap, w)); | |||
ret.copyLocationFrom(this); | |||
return ret; | |||
} | |||
@Override | |||
public Object accept(PatternNodeVisitor visitor, Object data) { | |||
return visitor.visit(this, data); | |||
} | |||
@Override | |||
public Object traverse(PatternNodeVisitor visitor, Object data) { | |||
Object ret = accept(visitor, data); | |||
this.body.traverse(visitor, ret); |
@@ -20,6 +20,7 @@ import org.aspectj.weaver.AjAttribute; | |||
import org.aspectj.weaver.CompressingDataOutputStream; | |||
import org.aspectj.weaver.ISourceContext; | |||
import org.aspectj.weaver.ResolvedType; | |||
import org.aspectj.weaver.UnresolvedType; | |||
import org.aspectj.weaver.VersionedDataInputStream; | |||
import org.aspectj.weaver.World; | |||
@@ -118,7 +119,7 @@ public class NotTypePattern extends TypePattern { | |||
} | |||
@Override | |||
public TypePattern parameterizeWith(Map typeVariableMap, World w) { | |||
public TypePattern parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) { | |||
TypePattern newNegatedPattern = negatedPattern.parameterizeWith(typeVariableMap, w); | |||
NotTypePattern ret = new NotTypePattern(newNegatedPattern); | |||
ret.copyLocationFrom(this); |
@@ -9,13 +9,10 @@ | |||
* Contributors: | |||
* PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.weaver.patterns; | |||
import org.aspectj.weaver.IHasPosition; | |||
public class ParserException extends RuntimeException { | |||
private IHasPosition token; | |||
@@ -346,7 +346,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { | |||
} | |||
@Override | |||
public AnnotationTypePattern parameterizeWith(Map typeVariableMap, World w) { | |||
public AnnotationTypePattern parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) { | |||
WildAnnotationTypePattern ret = new WildAnnotationTypePattern(typePattern.parameterizeWith(typeVariableMap, w)); | |||
ret.copyLocationFrom(this); | |||
ret.resolved = resolved; |