import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
public static final Kind Initialization = new Kind(JoinPoint.INITIALIZATION, 10, false);
public static final Kind ExceptionHandler = new Kind(JoinPoint.EXCEPTION_HANDLER, 11, true);
+ // Bits here are 1<<(Kind.getKey()) - and unfortunately keys didn't start at zero so bits here start at 2
+ public static final int MethodCallBit = 0x002;
+ public static final int ConstructorCallBit = 0x004;
+ public static final int MethodExecutionBit = 0x008;
+ public static final int ConstructorExecutionBit = 0x010;
+ public static final int FieldGetBit = 0x020;
+ public static final int FieldSetBit = 0x040;
+ public static final int StaticInitializationBit = 0x080;
+ public static final int PreInitializationBit = 0x100;
+ public static final int AdviceExecutionBit = 0x200;
+ public static final int InitializationBit = 0x400;
+ public static final int ExceptionHandlerBit = 0x800;
+
public static final int MAX_SHADOW_KIND = 11;
public static final Kind[] SHADOW_KINDS = new Kind[] {
MethodCall, ConstructorCall, MethodExecution, ConstructorExecution,
FieldGet, FieldSet, StaticInitialization, PreInitialization,
AdviceExecution, Initialization, ExceptionHandler,
};
-
- public static final Set ALL_SHADOW_KINDS;
+
+ public static final int ALL_SHADOW_KINDS_BITS;
+ public static final int NO_SHADOW_KINDS_BITS;
+
static {
- HashSet aSet = new HashSet();
- for (int i = 0; i < SHADOW_KINDS.length; i++) {
- aSet.add(SHADOW_KINDS[i]);
- }
- ALL_SHADOW_KINDS = Collections.unmodifiableSet(aSet);
+ ALL_SHADOW_KINDS_BITS = 0xffe;
+ NO_SHADOW_KINDS_BITS = 0x000;
}
+
+ /**
+ * Return count of how many bits set in the supplied parameter.
+ */
+ public static int howMany(int i) {
+ int count = 0;
+ for (int j = 0; j <SHADOW_KINDS.length; j++) {
+ if ((i&SHADOW_KINDS[j].bit)!=0) count++;
+ }
+ return count;
+ }
/** A type-safe enum representing the kind of shadows
*/
public static final class Kind extends TypeSafeEnum {
// private boolean argsOnStack; //XXX unused
+ public int bit;
+
public Kind(String name, int key, boolean argsOnStack) {
super(name, key);
+ bit = 1<<key;
// this.argsOnStack = argsOnStack;
}
return true;
}
+ public boolean isSet(int i) {
+ return (i&bit)!=0;
+ }
+
// XXX revisit along with removal of priorities
public boolean hasHighPriorityExceptions() {
return !isTargetSameAsThis();
}
+
+ private final static int hasReturnValueFlag =
+ MethodCallBit | ConstructorCallBit | MethodExecutionBit | FieldGetBit | AdviceExecutionBit;
/**
* These shadow kinds have return values that can be bound in
* after returning(Dooberry doo) advice.
* @return
*/
public boolean hasReturnValue() {
- return
- this == MethodCall ||
- this == ConstructorCall ||
- this == MethodExecution ||
- this == FieldGet ||
- this == AdviceExecution;
+ return (bit&hasReturnValueFlag)!=0;
}
+ private final static int isEnclosingKindFlag =
+ MethodExecutionBit | ConstructorExecutionBit | AdviceExecutionBit | StaticInitializationBit | InitializationBit;
/**
* These are all the shadows that contains other shadows within them and
* are often directly associated with methods.
*/
public boolean isEnclosingKind() {
- return this == MethodExecution || this == ConstructorExecution ||
- this == AdviceExecution || this == StaticInitialization
- || this == Initialization;
+ return (bit&isEnclosingKindFlag)!=0;
}
+ private final static int isTargetSameAsThisFlag =
+ MethodExecutionBit | ConstructorExecutionBit | StaticInitializationBit |
+ PreInitializationBit | AdviceExecutionBit | InitializationBit;
public boolean isTargetSameAsThis() {
- return this == MethodExecution
- || this == ConstructorExecution
- || this == StaticInitialization
- || this == PreInitialization
- || this == AdviceExecution
- || this == Initialization;
+ return (bit&isTargetSameAsThisFlag)!=0;
}
+ private final static int neverHasTargetFlag=
+ ConstructorCallBit | ExceptionHandlerBit | PreInitializationBit | StaticInitializationBit;
public boolean neverHasTarget() {
- return this == ConstructorCall
- || this == ExceptionHandler
- || this == PreInitialization
- || this == StaticInitialization;
+ return (bit&neverHasTargetFlag)!=0;
}
-
+
+ private final static int neverHasThisFlag=
+ PreInitializationBit | StaticInitializationBit;
public boolean neverHasThis() {
- return this == PreInitialization
- || this == StaticInitialization;
+ return (bit&neverHasThisFlag)!=0;
}
public String toResolvedString(World world) {
return getKind() + "(" + world.resolve(getSignature()).toGenericString() + ")";
}
+
+ /**
+ * Convert a bit array for the shadow kinds into a set of them... should only
+ * be used for testing - mainline code should do bit manipulation!
+ */
+ public static Set toSet(int i) {
+ Set results = new HashSet();
+ for (int j = 0; j < Shadow.SHADOW_KINDS.length; j++) {
+ Kind k = Shadow.SHADOW_KINDS[j];
+ if (k.isSet(i)) results.add(k);
+ }
+ return results;
+ }
+
}
}
for (Iterator iter = shadowMungers.iterator(); iter.hasNext();) {
ShadowMunger munger = (ShadowMunger) iter.next();
- Set couldMatchKinds = munger.getPointcut().couldMatchKinds();
- for (Iterator kindIterator = couldMatchKinds.iterator();
- kindIterator.hasNext();) {
- Shadow.Kind aKind = (Shadow.Kind) kindIterator.next();
- perKindShadowMungers[aKind.getKey()].add(munger);
+
+ int couldMatchKinds = munger.getPointcut().couldMatchKinds();
+ for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
+ Shadow.Kind kind = Shadow.SHADOW_KINDS[i];
+ if (kind.isSet(couldMatchKinds)) perKindShadowMungers[kind.getKey()].add(munger);
}
+
+// Set couldMatchKinds = munger.getPointcut().couldMatchKinds();
+// for (Iterator kindIterator = couldMatchKinds.iterator();
+// kindIterator.hasNext();) {
+// Shadow.Kind aKind = (Shadow.Kind) kindIterator.next();
+// perKindShadowMungers[aKind.getKey()].add(munger);
+// }
}
if (!perKindShadowMungers[Shadow.Initialization.getKey()].isEmpty())
import org.aspectj.weaver.ReferenceTypeDelegate;
import org.aspectj.weaver.ResolvedTypeMunger;
import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.ShadowMunger;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.WeaverMessages;
// common.
private void validateBindings(Pointcut dnfPointcut, Pointcut userPointcut, int numFormals, String[] names) {
if (numFormals == 0) return; // nothing to check
- if (dnfPointcut.couldMatchKinds().isEmpty()) return; // cant have problems if you dont match!
+ if (dnfPointcut.couldMatchKinds()==Shadow.NO_SHADOW_KINDS_BITS) return; // cant have problems if you dont match!
if (dnfPointcut instanceof OrPointcut) {
OrPointcut orBasedDNFPointcut = (OrPointcut) dnfPointcut;
Pointcut[] leftBindings = new Pointcut[numFormals];
Pointcut[] newRightBindings = new Pointcut[numFormals];
validateOrBranch((OrPointcut)left,userPointcut,numFormals,names,leftBindings,newRightBindings);
} else {
- if (left.couldMatchKinds().size() > 0)
+ if (left.couldMatchKinds()!=Shadow.NO_SHADOW_KINDS_BITS)
validateSingleBranch(left, userPointcut, numFormals, names, leftBindings);
}
if (right instanceof OrPointcut) {
Pointcut[] newLeftBindings = new Pointcut[numFormals];
validateOrBranch((OrPointcut)right,userPointcut,numFormals,names,newLeftBindings,rightBindings);
} else {
- if (right.couldMatchKinds().size() > 0)
+ if (right.couldMatchKinds()!=Shadow.NO_SHADOW_KINDS_BITS)
validateSingleBranch(right, userPointcut, numFormals, names, rightBindings);
}
- Set kindsInCommon = left.couldMatchKinds();
- kindsInCommon.retainAll(right.couldMatchKinds());
- if (!kindsInCommon.isEmpty() && couldEverMatchSameJoinPoints(left,right)) {
+ int kindsInCommon = left.couldMatchKinds() & right.couldMatchKinds();
+ if (kindsInCommon!=Shadow.NO_SHADOW_KINDS_BITS && couldEverMatchSameJoinPoints(left,right)) {
// we know that every branch binds every formal, so there is no ambiguity
// if each branch binds it in exactly the same way...
List ambiguousNames = new ArrayList();
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;
-import java.util.Set;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.IntMap;
/* (non-Javadoc)
* @see org.aspectj.weaver.patterns.Pointcut#couldMatchKinds()
*/
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS;
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS;
}
/* (non-Javadoc)
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.ISourceContext;
public class AndPointcut extends Pointcut {
Pointcut left, right; // exposed for testing
- private Set couldMatchKinds;
+ private int couldMatchKinds;
public AndPointcut(Pointcut left, Pointcut right) {
super();
this.right = right;
this.pointcutKind = AND;
setLocation(left.getSourceContext(), left.getStart(), right.getEnd());
- couldMatchKinds = new HashSet();
- couldMatchKinds.addAll(left.couldMatchKinds());
- couldMatchKinds.retainAll(right.couldMatchKinds());
+ couldMatchKinds = left.couldMatchKinds() & right.couldMatchKinds();
}
- public Set couldMatchKinds() {
+ public int couldMatchKinds() {
return couldMatchKinds;
}
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FuzzyBoolean;
return annotationTypePattern;
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS;
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS;
}
public Pointcut parameterizeWith(Map typeVariableMap) {
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
return arguments;
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS; // empty args() matches jps with no args
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS; // empty args() matches jps with no args
}
public Pointcut parameterizeWith(Map typeVariableMap) {
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
return ret;
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS; // empty args() matches jps with no args
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS; // empty args() matches jps with no args
}
public FuzzyBoolean fastMatch(FastMatchInfo type) {
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.IMessage;
import org.aspectj.util.FileUtil;
import org.aspectj.weaver.IntMap;
import org.aspectj.weaver.Member;
import org.aspectj.weaver.NameMangler;
-import org.aspectj.weaver.ResolvedMemberImpl;
import org.aspectj.weaver.ResolvedMember;
+import org.aspectj.weaver.ResolvedMemberImpl;
import org.aspectj.weaver.ResolvedPointcutDefinition;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.Shadow;
return isBelow;
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS;
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS;
}
// enh 76055
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.IntMap;
this.pointcutKind = CFLOW;
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS;
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS;
}
public FuzzyBoolean fastMatch(FastMatchInfo type) {
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FuzzyBoolean;
public class HandlerPointcut extends Pointcut {
TypePattern exceptionType;
- private static final Set MATCH_KINDS = new HashSet();
- static {
- MATCH_KINDS.add(Shadow.ExceptionHandler);
- }
+ private static final int MATCH_KINDS = Shadow.ExceptionHandler.bit;
public HandlerPointcut(TypePattern exceptionType) {
this.exceptionType = exceptionType;
this.pointcutKind = HANDLER;
}
- public Set couldMatchKinds() {
+ public int couldMatchKinds() {
return MATCH_KINDS;
}
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.IMessage;
import org.aspectj.lang.JoinPoint;
this.extraParameterFlags = -1;//allows to keep track of the @Aj style
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS;
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS;
}
public FuzzyBoolean fastMatch(FastMatchInfo type) {
this.pointcutKind = Pointcut.IF_FALSE;
}
- public Set couldMatchKinds() {
- return Collections.EMPTY_SET;
+ public int couldMatchKinds() {
+ return Shadow.NO_SHADOW_KINDS_BITS;
}
public boolean alwaysFalse() {
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.MessageUtil;
public class KindedPointcut extends Pointcut {
Shadow.Kind kind;
private SignaturePattern signature;
- private Set matchKinds;
+ private int matchKinds;
private ShadowMunger munger = null; // only set after concretization
this.kind = kind;
this.signature = signature;
this.pointcutKind = KINDED;
- this.matchKinds = new HashSet();
- matchKinds.add(kind);
+ this.matchKinds = kind.bit;
}
public KindedPointcut(
Shadow.Kind kind,
/* (non-Javadoc)
* @see org.aspectj.weaver.patterns.Pointcut#couldMatchKinds()
*/
- public Set couldMatchKinds() {
+ public int couldMatchKinds() {
return matchKinds;
}
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;
-import java.util.Set;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.ISourceContext;
setLocation(pointcut.getSourceContext(), startPos, pointcut.getEnd());
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS;
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS;
}
public Pointcut getNegatedPointcut() { return body; }
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.ISourceContext;
public class OrPointcut extends Pointcut {
Pointcut left, right;
- private Set couldMatchKinds;
+ private int couldMatchKinds;
public OrPointcut(Pointcut left, Pointcut right) {
super();
this.right = right;
setLocation(left.getSourceContext(), left.getStart(), right.getEnd());
this.pointcutKind = OR;
- this.couldMatchKinds = new HashSet(left.couldMatchKinds());
- this.couldMatchKinds.addAll(right.couldMatchKinds());
+ this.couldMatchKinds = left.couldMatchKinds() | right.couldMatchKinds();
}
- public Set couldMatchKinds() {
+ public int couldMatchKinds() {
return couldMatchKinds;
}
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.Advice;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
import org.aspectj.weaver.ast.Expr;
import org.aspectj.weaver.ast.Test;
+import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
public class PerCflow extends PerClause {
private boolean isBelow;
return visitor.visit(this,data);
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS;
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS;
}
public FuzzyBoolean fastMatch(FastMatchInfo type) {
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FuzzyBoolean;
return visitor.visit(this,data);
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS;
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS;
}
public FuzzyBoolean fastMatch(FastMatchInfo type) {
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.Advice;
import org.aspectj.weaver.AjcMemberMaker;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.PerObjectInterfaceTypeMunger;
-import org.aspectj.weaver.ResolvedTypeMunger;
import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.ResolvedTypeMunger;
import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
import org.aspectj.weaver.ast.Expr;
import org.aspectj.weaver.ast.Test;
import org.aspectj.weaver.ast.Var;
+import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
public class PerObject extends PerClause {
private boolean isThis;
private Pointcut entry;
- private static final Set thisKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
- private static final Set targetKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
+
+ private static final int thisKindSet;
+ private static final int targetKindSet;
+
static {
- for (Iterator iter = Shadow.ALL_SHADOW_KINDS.iterator(); iter.hasNext();) {
- Shadow.Kind kind = (Shadow.Kind) iter.next();
- if (kind.neverHasThis()) thisKindSet.remove(kind);
- if (kind.neverHasTarget()) targetKindSet.remove(kind);
+ int thisFlags = Shadow.ALL_SHADOW_KINDS_BITS;
+ int targFlags = Shadow.ALL_SHADOW_KINDS_BITS;
+ for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
+ Shadow.Kind kind = Shadow.SHADOW_KINDS[i];
+ if (kind.neverHasThis()) thisFlags-=kind.bit;
+ if (kind.neverHasTarget()) targFlags-=kind.bit;
}
+ thisKindSet = thisFlags;
+ targetKindSet=targFlags;
}
public PerObject(Pointcut entry, boolean isThis) {
return visitor.visit(this,data);
}
- public Set couldMatchKinds() {
+ public int couldMatchKinds() {
return isThis ? thisKindSet : targetKindSet;
}
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;
-import java.util.Set;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.AjcMemberMaker;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.VersionedDataInputStream;
-import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
import org.aspectj.weaver.ast.Expr;
import org.aspectj.weaver.ast.Literal;
import org.aspectj.weaver.ast.Test;
+import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
public class PerSingleton extends PerClause {
public PerSingleton() {
return visitor.visit(this,data);
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS;
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS;
}
public FuzzyBoolean fastMatch(FastMatchInfo type) {
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.weaver.AjcMemberMaker;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.Member;
-//import org.aspectj.weaver.PerTypeWithinTargetTypeMunger;
import org.aspectj.weaver.PerTypeWithinTargetTypeMunger;
-import org.aspectj.weaver.ResolvedTypeMunger;
import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.ResolvedTypeMunger;
import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
import org.aspectj.weaver.ast.Expr;
import org.aspectj.weaver.ast.Literal;
import org.aspectj.weaver.ast.Test;
+import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
// PTWIMPL Represents a parsed pertypewithin()
private TypePattern typePattern;
// Any shadow could be considered within a pertypewithin() type pattern
- private static final Set kindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
+ private static final int kindSet = Shadow.ALL_SHADOW_KINDS_BITS;
public TypePattern getTypePattern() {
return typePattern;
return visitor.visit(this,data);
}
- public Set couldMatchKinds() {
+ public int couldMatchKinds() {
return kindSet;
}
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.Collections;
import java.util.Map;
-import java.util.Set;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.util.TypeSafeEnum;
public abstract FuzzyBoolean fastMatch(FastMatchInfo info);
/**
- * The set of ShadowKinds that this Pointcut could possibly match
+ * The set of ShadowKinds that this Pointcut could possibly match -
+ * an int whose bits are set according to the Kinds specified in Shadow.java
*/
- public abstract /*Enum*/Set/*<Shadow.Kind>*/ couldMatchKinds();
+ public abstract int couldMatchKinds();
public String[] getTypeVariablesInScope() {
return typeVariablesInScope;
if (shadow.shadowId == lastMatchedShadowId) return lastMatchedShadowResult;
FuzzyBoolean ret;
// this next test will prevent a lot of un-needed matching going on....
- if (couldMatchKinds().contains(shadow.getKind())) {
+ if (shadow.getKind().isSet(couldMatchKinds())) {
ret = matchInternal(shadow);
} else {
ret = FuzzyBoolean.NO;
return Literal.FALSE; // can only get here if an earlier error occurred
}
- public Set couldMatchKinds() {
- return Collections.EMPTY_SET;
+ public int couldMatchKinds() {
+ return Shadow.NO_SHADOW_KINDS_BITS;
}
public FuzzyBoolean fastMatch(FastMatchInfo type) {
// a higher score means a more expensive evaluation
private int getScore(Pointcut p) {
- if (p.couldMatchKinds().isEmpty()) return MATCHES_NOTHING;
+ if (p.couldMatchKinds()==Shadow.NO_SHADOW_KINDS_BITS) return MATCHES_NOTHING;
if (p instanceof WithinPointcut) return WITHIN;
if (p instanceof WithinAnnotationPointcut) return ATWITHIN;
if (p instanceof KindedPointcut) {
if (((IfPointcut)element).alwaysFalse()) return Pointcut.makeMatchesNothing(element.state);
}
// If it can't match anything, the whole AND can't match anything
- if (element.couldMatchKinds().isEmpty()) return element;
+ if (element.couldMatchKinds()==Shadow.NO_SHADOW_KINDS_BITS) return element;
}
- if (apc.couldMatchKinds().isEmpty()) return Pointcut.makeMatchesNothing(apc.state);
+ if (apc.couldMatchKinds()==Shadow.NO_SHADOW_KINDS_BITS) return Pointcut.makeMatchesNothing(apc.state);
// write out with cheapest on left
Iterator iter = nodes.iterator();
Pointcut result = (Pointcut) iter.next();
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.MessageUtil;
this.pointcutKind = REFERENCE;
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS;
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS;
}
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.MessageUtil;
private ExactAnnotationTypePattern annotationTypePattern;
private ShadowMunger munger;
private String declarationText;
- private static final Set thisKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
- private static final Set targetKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
+
+ private static final int thisKindSet;
+ private static final int targetKindSet;
+
static {
- for (Iterator iter = Shadow.ALL_SHADOW_KINDS.iterator(); iter.hasNext();) {
- Shadow.Kind kind = (Shadow.Kind) iter.next();
- if (kind.neverHasThis()) thisKindSet.remove(kind);
- if (kind.neverHasTarget()) targetKindSet.remove(kind);
+ int thisFlags = Shadow.ALL_SHADOW_KINDS_BITS;
+ int targFlags = Shadow.ALL_SHADOW_KINDS_BITS;
+ for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
+ Shadow.Kind kind = Shadow.SHADOW_KINDS[i];
+ if (kind.neverHasThis()) thisFlags-=kind.bit;
+ if (kind.neverHasTarget()) targFlags-=kind.bit;
}
+ thisKindSet = thisFlags;
+ targetKindSet=targFlags;
}
/**
return annotationTypePattern;
}
- public Set couldMatchKinds() {
+ public int couldMatchKinds() {
return isThis ? thisKindSet : targetKindSet;
}
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.MessageUtil;
private TypePattern type;
private String declarationText;
- private static final Set thisKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
- private static final Set targetKindSet = new HashSet(Shadow.ALL_SHADOW_KINDS);
+ private static final int thisKindSet;
+ private static final int targetKindSet;
+
static {
- for (Iterator iter = Shadow.ALL_SHADOW_KINDS.iterator(); iter.hasNext();) {
- Shadow.Kind kind = (Shadow.Kind) iter.next();
- if (kind.neverHasThis()) thisKindSet.remove(kind);
- if (kind.neverHasTarget()) targetKindSet.remove(kind);
+ int thisFlags = Shadow.ALL_SHADOW_KINDS_BITS;
+ int targFlags = Shadow.ALL_SHADOW_KINDS_BITS;
+ for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
+ Shadow.Kind kind = Shadow.SHADOW_KINDS[i];
+ if (kind.neverHasThis()) thisFlags-=kind.bit;
+ if (kind.neverHasTarget()) targFlags-=kind.bit;
}
+ thisKindSet = thisFlags;
+ targetKindSet=targFlags;
}
+
public boolean isBinding() {
return (type instanceof BindingTypePattern);
}
return ret;
}
- public Set couldMatchKinds() {
+ public int couldMatchKinds() {
return isThis ? thisKindSet : targetKindSet;
}
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.MessageUtil;
return annotationTypePattern;
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS;
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS;
}
public Pointcut parameterizeWith(Map typeVariableMap) {
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FuzzyBoolean;
private ExactAnnotationTypePattern annotationTypePattern;
private ShadowMunger munger = null; // only set after concretization
private String declarationText;
- private static final Set matchedShadowKinds = new HashSet();
+
+ private static final int matchedShadowKinds;
static {
- matchedShadowKinds.addAll(Shadow.ALL_SHADOW_KINDS);
+ int flags = Shadow.ALL_SHADOW_KINDS_BITS;
for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
if (Shadow.SHADOW_KINDS[i].isEnclosingKind())
- matchedShadowKinds.remove(Shadow.SHADOW_KINDS[i]);
+ flags -= Shadow.SHADOW_KINDS[i].bit;
}
+ matchedShadowKinds=flags;
}
public WithinCodeAnnotationPointcut(ExactAnnotationTypePattern type) {
return annotationTypePattern;
}
- public Set couldMatchKinds() {
+ public int couldMatchKinds() {
return matchedShadowKinds;
}
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.MessageUtil;
return FuzzyBoolean.NO;
}
- public Set couldMatchKinds() {
- return Shadow.ALL_SHADOW_KINDS;
+ public int couldMatchKinds() {
+ return Shadow.ALL_SHADOW_KINDS_BITS;
}
public Pointcut parameterizeWith(Map typeVariableMap) {
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FuzzyBoolean;
public class WithincodePointcut extends Pointcut {
private SignaturePattern signature;
- private static final Set matchedShadowKinds = new HashSet();
+ private static final int matchedShadowKinds;
static {
- matchedShadowKinds.addAll(Shadow.ALL_SHADOW_KINDS);
+ int flags = Shadow.ALL_SHADOW_KINDS_BITS;
for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) {
if (Shadow.SHADOW_KINDS[i].isEnclosingKind())
- matchedShadowKinds.remove(Shadow.SHADOW_KINDS[i]);
+ flags -= Shadow.SHADOW_KINDS[i].bit;
}
// these next two are needed for inlining of field initializers
- matchedShadowKinds.add(Shadow.ConstructorExecution);
- matchedShadowKinds.add(Shadow.Initialization);
+ flags|=Shadow.ConstructorExecution.bit;
+ flags|=Shadow.Initialization.bit;
+ matchedShadowKinds = flags;
}
public WithincodePointcut(SignaturePattern signature) {
return signature;
}
- public Set couldMatchKinds() {
+ public int couldMatchKinds() {
return matchedShadowKinds;
}
public void testDetermineKindSetOfAnd() {
Pointcut oneKind = getPointcut("execution(* foo(..)) && this(Boo)");
AndPointcut rewritten = (AndPointcut) prw.rewrite(oneKind);
- assertEquals("Only one kind",1,rewritten.couldMatchKinds().size());
- assertTrue("It's Shadow.MethodExecution",rewritten.couldMatchKinds().contains(Shadow.MethodExecution));
+ assertEquals("Only one kind",1,Shadow.howMany(rewritten.couldMatchKinds()));
+ assertTrue("It's Shadow.MethodExecution",Shadow.MethodExecution.isSet(rewritten.couldMatchKinds()));
}
public void testKindSetOfExecution() {
Pointcut p = getPointcut("execution(* foo(..))");
- assertEquals("Only one kind",1,p.couldMatchKinds().size());
- assertTrue("It's Shadow.MethodExecution",p.couldMatchKinds().contains(Shadow.MethodExecution));
+ assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+ assertTrue("It's Shadow.MethodExecution",Shadow.MethodExecution.isSet(p.couldMatchKinds()));
p = getPointcut("execution(new(..))");
- assertEquals("Only one kind",1,p.couldMatchKinds().size());
- assertTrue("It's Shadow.ConstructorExecution",p.couldMatchKinds().contains(Shadow.ConstructorExecution));
+ assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+ assertTrue("It's Shadow.ConstructorExecution",Shadow.ConstructorExecution.isSet(p.couldMatchKinds()));
}
public void testKindSetOfCall() {
Pointcut p = getPointcut("call(* foo(..))");
- assertEquals("Only one kind",1,p.couldMatchKinds().size());
- assertTrue("It's Shadow.MethodCall",p.couldMatchKinds().contains(Shadow.MethodCall));
+ assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+ assertTrue("It's Shadow.MethodCall",Shadow.MethodCall.isSet(p.couldMatchKinds()));
p = getPointcut("call(new(..))");
- assertEquals("Only one kind",1,p.couldMatchKinds().size());
- assertTrue("It's Shadow.ConstructorCall",p.couldMatchKinds().contains(Shadow.ConstructorCall));
+ assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+ assertTrue("It's Shadow.ConstructorCall",Shadow.ConstructorCall.isSet(p.couldMatchKinds()));
}
public void testKindSetOfAdviceExecution() {
Pointcut p = getPointcut("adviceexecution()");
- assertEquals("Only one kind",1,p.couldMatchKinds().size());
- assertTrue("It's Shadow.AdviceExecution",p.couldMatchKinds().contains(Shadow.AdviceExecution));
+ assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+ assertTrue("It's Shadow.AdviceExecution",Shadow.AdviceExecution.isSet(p.couldMatchKinds()));
}
public void testKindSetOfGet() {
Pointcut p = getPointcut("get(* *)");
- assertEquals("Only one kind",1,p.couldMatchKinds().size());
- assertTrue("It's Shadow.FieldGet",p.couldMatchKinds().contains(Shadow.FieldGet));
+ assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+ assertTrue("It's Shadow.FieldGet",Shadow.FieldGet.isSet(p.couldMatchKinds()));
}
public void testKindSetOfSet() {
Pointcut p = getPointcut("set(* *)");
- assertEquals("Only one kind",1,p.couldMatchKinds().size());
- assertTrue("It's Shadow.FieldSet",p.couldMatchKinds().contains(Shadow.FieldSet));
+ assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+ assertTrue("It's Shadow.FieldSet",Shadow.FieldSet.isSet(p.couldMatchKinds()));
}
public void testKindSetOfHandler() {
Pointcut p = getPointcut("handler(*)");
- assertEquals("Only one kind",1,p.couldMatchKinds().size());
- assertTrue("It's Shadow.ExceptionHandler",p.couldMatchKinds().contains(Shadow.ExceptionHandler));
+ assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+ assertTrue("It's Shadow.ExceptionHandler",Shadow.ExceptionHandler.isSet(p.couldMatchKinds()));
}
public void testKindSetOfInitialization() {
Pointcut p = getPointcut("initialization(new (..))");
- assertEquals("Only one kind",1,p.couldMatchKinds().size());
- assertTrue("It's Shadow.Initialization",p.couldMatchKinds().contains(Shadow.Initialization));
+ assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+ assertTrue("It's Shadow.Initialization",Shadow.Initialization.isSet(p.couldMatchKinds()));
}
public void testKindSetOfPreInitialization() {
Pointcut p = getPointcut("preinitialization(new (..))");
- assertEquals("Only one kind",1,p.couldMatchKinds().size());
- assertTrue("It's Shadow.PreInitialization",p.couldMatchKinds().contains(Shadow.PreInitialization));
+ assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+ assertTrue("It's Shadow.PreInitialization",Shadow.PreInitialization.isSet(p.couldMatchKinds()));
}
public void testKindSetOfStaticInitialization() {
Pointcut p = getPointcut("staticinitialization(*)");
- assertEquals("Only one kind",1,p.couldMatchKinds().size());
- assertTrue("It's Shadow.StaticInitialization",p.couldMatchKinds().contains(Shadow.StaticInitialization));
+ assertEquals("Only one kind",1,Shadow.howMany(p.couldMatchKinds()));
+ assertTrue("It's Shadow.StaticInitialization",Shadow.StaticInitialization.isSet(p.couldMatchKinds()));
}
public void testKindSetOfThis() {
Pointcut p = getPointcut("this(Foo)");
- Set matches = p.couldMatchKinds();
+ Set matches = Shadow.toSet(p.couldMatchKinds());
for (Iterator iter = matches.iterator(); iter.hasNext();) {
Shadow.Kind kind = (Shadow.Kind) iter.next();
assertFalse("No kinds that don't have a this",kind.neverHasThis());
}
// + @
p = getPointcut("@this(Foo)");
- matches = p.couldMatchKinds();
+ matches = Shadow.toSet(p.couldMatchKinds());
for (Iterator iter = matches.iterator(); iter.hasNext();) {
Shadow.Kind kind = (Shadow.Kind) iter.next();
assertFalse("No kinds that don't have a this",kind.neverHasThis());
public void testKindSetOfTarget() {
Pointcut p = getPointcut("target(Foo)");
- Set matches = p.couldMatchKinds();
+ Set matches = Shadow.toSet(p.couldMatchKinds());
for (Iterator iter = matches.iterator(); iter.hasNext();) {
Shadow.Kind kind = (Shadow.Kind) iter.next();
assertFalse("No kinds that don't have a target",kind.neverHasTarget());
}
// + @
p = getPointcut("@target(Foo)");
- matches = p.couldMatchKinds();
+ matches = Shadow.toSet(p.couldMatchKinds());
for (Iterator iter = matches.iterator(); iter.hasNext();) {
Shadow.Kind kind = (Shadow.Kind) iter.next();
assertFalse("No kinds that don't have a target",kind.neverHasTarget());
public void testKindSetOfArgs() {
Pointcut p = getPointcut("args(..)");
- assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+ assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
// + @
p = getPointcut("@args(..)");
- assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+ assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
}
public void testKindSetOfAnnotation() {
Pointcut p = getPointcut("@annotation(Foo)");
- assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+ assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
}
public void testKindSetOfWithin() {
Pointcut p = getPointcut("within(*)");
- assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+ assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
// + @
p = getPointcut("@within(Foo)");
- assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+ assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
}
public void testKindSetOfWithinCode() {
Pointcut p = getPointcut("withincode(* foo(..))");
- Set matches = p.couldMatchKinds();
+ Set matches = Shadow.toSet(p.couldMatchKinds());
for (Iterator iter = matches.iterator(); iter.hasNext();) {
Shadow.Kind kind = (Shadow.Kind) iter.next();
assertFalse("No kinds that are themselves enclosing",
assertTrue("Need init for inlined field inits",matches.contains(Shadow.Initialization));
// + @
p = getPointcut("@withincode(Foo)");
- matches = p.couldMatchKinds();
+ matches = Shadow.toSet(p.couldMatchKinds());
for (Iterator iter = matches.iterator(); iter.hasNext();) {
Shadow.Kind kind = (Shadow.Kind) iter.next();
assertFalse("No kinds that are themselves enclosing",kind.isEnclosingKind());
public void testKindSetOfIf() {
Pointcut p = new IfPointcut(null,0);
- assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+ assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
p = IfPointcut.makeIfTruePointcut(Pointcut.CONCRETE);
- assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+ assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
p = IfPointcut.makeIfFalsePointcut(Pointcut.CONCRETE);
- assertTrue("Nothing",p.couldMatchKinds().isEmpty());
+ assertTrue("Nothing",p.couldMatchKinds()==Shadow.NO_SHADOW_KINDS_BITS);
}
public void testKindSetOfCflow() {
Pointcut p = getPointcut("cflow(this(Foo))");
- assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+ assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
// [below]
p = getPointcut("cflowbelow(this(Foo))");
- assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+ assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
}
public void testKindSetInNegation() {
Pointcut p = getPointcut("!execution(new(..))");
- assertTrue("All kinds",p.couldMatchKinds().containsAll(Shadow.ALL_SHADOW_KINDS));
+ assertTrue("All kinds",p.couldMatchKinds()==Shadow.ALL_SHADOW_KINDS_BITS);
}
public void testKindSetOfOr() {
Pointcut p = getPointcut("execution(new(..)) || get(* *)");
- Set matches = p.couldMatchKinds();
+ Set matches = Shadow.toSet(p.couldMatchKinds());
assertEquals("2 kinds",2,matches.size());
assertTrue("ConstructorExecution",matches.contains(Shadow.ConstructorExecution));
assertTrue("FieldGet",matches.contains(Shadow.FieldGet));