private int requiredModifiers;
private int forbiddenModifiers;
+ public static final int TRIVIAL = 0x4000;
+
public static final ModifiersPattern ANY = new ModifiersPattern(0, 0);
public ModifiersPattern(int requiredModifiers, int forbiddenModifiers) {
}
public boolean matches(int modifiers) {
- return ((modifiers & requiredModifiers) == requiredModifiers) &&
- ((modifiers & forbiddenModifiers) == 0);
+ // Comparison here is based on 'real' Java modifiers
+ return (((modifiers & requiredModifiers)&0xfff) == (requiredModifiers&0xfff)) &&
+ (((modifiers & forbiddenModifiers)&0xfff) == 0);
}
private static Map modifierFlags = null;
-
+
public static int getModifierFlag(String name) {
+ return getModifierFlag(name,false);
+ }
+
+ public static int getModifierFlag(String name,boolean allowTrivial) {
if (modifierFlags == null) {
modifierFlags = new HashMap();
int flag = 1;
modifierFlags.put(flagName, new Integer(flag));
flag = flag << 1;
}
+ modifierFlags.put("trivial",new Integer(TRIVIAL));
}
Integer flag = (Integer)modifierFlags.get(name);
if (flag == null) return -1;
+ if (flag.intValue()==TRIVIAL && !allowTrivial) return -2;
return flag.intValue();
}
+
+ public boolean concernedWithTriviality() {
+ return ((requiredModifiers|forbiddenModifiers)&TRIVIAL)!=0;
+ }
+
+ public boolean matchesTriviality(boolean isTrivial) {
+ int matchMods = (isTrivial?TRIVIAL:0x0000);
+ return ((matchMods & requiredModifiers) == requiredModifiers) &&
+ ((matchMods & forbiddenModifiers) == 0);
+ }
+
+ public boolean requires(int flag) {
+ return ((requiredModifiers&flag)!=0);
+ }
public Object accept(PatternNodeVisitor visitor, Object data) {
return visitor.visit(this, data);
}
-}
+}
\ No newline at end of file
Shadow.Kind shadowKind = null;
if (kind.equals("execution")) {
- sig = parseMethodOrConstructorSignaturePattern();
+ sig = parseMethodOrConstructorSignaturePattern(true);
if (sig.getKind() == Member.METHOD) {
shadowKind = Shadow.MethodExecution;
} else if (sig.getKind() == Member.CONSTRUCTOR) {
return first.getEnd() == second.getStart()-1;
}
-
public ModifiersPattern parseModifiersPattern() {
+ return parseModifiersPattern(false);
+ }
+
+ public ModifiersPattern parseModifiersPattern(boolean allowTrivial) {
int requiredFlags = 0;
int forbiddenFlags = 0;
int start;
boolean isForbidden = false;
isForbidden = maybeEat("!");
IToken t = tokenSource.next();
- int flag = ModifiersPattern.getModifierFlag(t.getString());
+ int flag = ModifiersPattern.getModifierFlag(t.getString(),allowTrivial);
+ // working out the flag...
+ if (flag==-2) {
+ throw new ParserException("any modifier except 'trivial'",t);//tokenSource.peek(-1));
+ }
if (flag == -1) break;
if (isForbidden) forbiddenFlags |= flag;
else requiredFlags |= flag;
return ThrowsPattern.ANY;
}
-
public SignaturePattern parseMethodOrConstructorSignaturePattern() {
+ return parseMethodOrConstructorSignaturePattern(false);
+ }
+
+ public SignaturePattern parseMethodOrConstructorSignaturePattern(boolean allowTrivial) {
int startPos = tokenSource.peek().getStart();
AnnotationTypePattern annotationPattern = maybeParseAnnotationPattern();
- ModifiersPattern modifiers = parseModifiersPattern();
+ ModifiersPattern modifiers = parseModifiersPattern(allowTrivial);
TypePattern returnType = parseTypePattern(false);
TypePattern declaringType;
import java.util.Set;
import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.bridge.MessageUtil;
import org.aspectj.lang.Signature;
import org.aspectj.lang.reflect.FieldSignature;
import org.aspectj.lang.reflect.MethodSignature;
}
if (matchesIgnoringAnnotations.alwaysFalse()) return FuzzyBoolean.NO;
+
+
+ // last thing to try
+ if (subjectMatch && modifiers.concernedWithTriviality()) {
+ if (!inAWorld.isJoinpointTrivialEnabled()) {
+ inAWorld.getMessageHandler().handleMessage(MessageUtil.warn("pointcuts can not use trivial modifier unless -Xjoinpoints:trivial specified"));
+ } else {
+ ResolvedMember rm = aMember.resolve(inAWorld);
+ boolean isTrivial = rm.isTrivial();
+ if (!modifiers.matchesTriviality(isTrivial)) return FuzzyBoolean.NO;
+ }
+ }
+
// annotations match on the *subject*
if (subjectMatch && !matchesAnnotations(aMember,inAWorld).alwaysTrue()) {
return FuzzyBoolean.NO;