]> source.dussan.org Git - aspectj.git/commitdiff
more tests
authoraclement <aclement>
Wed, 10 Dec 2008 19:15:12 +0000 (19:15 +0000)
committeraclement <aclement>
Wed, 10 Dec 2008 19:15:12 +0000 (19:15 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/internal/tools/StandardPointcutExpressionImpl.java
org.aspectj.matcher/src/org/aspectj/weaver/reflect/StandardShadow.java
org.aspectj.matcher/src/org/aspectj/weaver/reflect/StandardShadowMatchImpl.java [new file with mode: 0644]
org.aspectj.matcher/src/org/aspectj/weaver/tools/StandardPointcutExpression.java
org.aspectj.matcher/testsrc/org/aspectj/matcher/tools/CommonPointcutExpressionTests.java
org.aspectj.matcher/testsrc/org/aspectj/matcher/tools/FurtherCommonPointcutExpressionTests.java [new file with mode: 0644]

index 2459366f002a0db6b61f30edff50b4712f4707bd..1e90437528016a4d440019cc7d4c747ffcb6bde0 100644 (file)
@@ -10,9 +10,7 @@
 package org.aspectj.weaver.internal.tools;
 
 import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
 import java.lang.reflect.Member;
-import java.lang.reflect.Method;
 
 import org.aspectj.weaver.ResolvedMember;
 import org.aspectj.weaver.ResolvedType;
@@ -35,9 +33,8 @@ import org.aspectj.weaver.patterns.ThisOrTargetPointcut;
 import org.aspectj.weaver.patterns.WithinAnnotationPointcut;
 import org.aspectj.weaver.patterns.WithinCodeAnnotationPointcut;
 import org.aspectj.weaver.reflect.ReflectionFastMatchInfo;
-import org.aspectj.weaver.reflect.ReflectionShadow;
-import org.aspectj.weaver.reflect.ShadowMatchImpl;
 import org.aspectj.weaver.reflect.StandardShadow;
+import org.aspectj.weaver.reflect.StandardShadowMatchImpl;
 import org.aspectj.weaver.tools.DefaultMatchingContext;
 import org.aspectj.weaver.tools.MatchingContext;
 import org.aspectj.weaver.tools.PointcutParameter;
@@ -93,179 +90,181 @@ public class StandardPointcutExpressionImpl implements StandardPointcutExpressio
                return new ExposedState(parameters.length);
        }
 
-       public ShadowMatch matchesMethodExecution(Method aMethod) {
-               return matchesExecution(aMethod);
-       }
+       // public ShadowMatch matchesMethodExecution(Method aMethod) {
+       // return matchesExecution(aMethod);
+       // }
 
        public ShadowMatch matchesMethodExecution(ResolvedMember aMethod) {
                return matchesExecution(aMethod);
        }
 
        public ShadowMatch matchesConstructorExecution(Constructor aConstructor) {
-               return matchesExecution(aConstructor);
+               return null;
+               // return matchesExecution(aConstructor);
        }
 
-       private ShadowMatch matchesExecution(Member aMember) {
-               Shadow s = ReflectionShadow.makeExecutionShadow(world, aMember, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(aMember);
-               sm.setWithinCode(null);
-               sm.setWithinType(aMember.getDeclaringClass());
-               return sm;
-       }
+       // private ShadowMatch matchesExecution(Member aMember) {
+       // Shadow s = ReflectionShadow.makeExecutionShadow(world, aMember, this.matchContext);
+       // ShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(aMember);
+       // sm.setWithinCode(null);
+       // sm.setWithinType(aMember.getDeclaringClass());
+       // return sm;
+       // }
 
        private ShadowMatch matchesExecution(ResolvedMember aMember) {
                Shadow s = StandardShadow.makeExecutionShadow(world, aMember, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               // sm.setSubject(aMember);
-               // sm.setWithinCode(null);
-               // sm.setWithinType(aMember.getDeclaringClass());
-               return sm;
-       }
-
-       public ShadowMatch matchesStaticInitialization(Class aClass) {
-               Shadow s = ReflectionShadow.makeStaticInitializationShadow(world, aClass, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(null);
+               StandardShadowMatchImpl sm = getShadowMatch(s);
+               sm.setSubject(aMember);
                sm.setWithinCode(null);
-               sm.setWithinType(aClass);
+               sm.setWithinType((ResolvedType) aMember.getDeclaringType());
                return sm;
        }
 
-       public ShadowMatch matchesStaticInitialization(ResolvedType type) {
-               Shadow s = StandardShadow.makeStaticInitializationShadow(world, type, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
+       // public ShadowMatch matchesStaticInitialization(Class aClass) {
+       // Shadow s = ReflectionShadow.makeStaticInitializationShadow(world, aClass, this.matchContext);
+       // StandardShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(null);
+       // sm.setWithinCode(null);
+       // sm.setWithinType(aClass);
+       // return sm;
+       // }
+
+       public ShadowMatch matchesStaticInitialization(ResolvedType aType) {
+               Shadow s = StandardShadow.makeStaticInitializationShadow(world, aType, this.matchContext);
+               StandardShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(null);
                sm.setWithinCode(null);
-               // sm.setWithinType(aClass);
-               return sm;
-       }
-
-       public ShadowMatch matchesAdviceExecution(Method aMethod) {
-               Shadow s = ReflectionShadow.makeAdviceExecutionShadow(world, aMethod, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(aMethod);
-               sm.setWithinCode(null);
-               sm.setWithinType(aMethod.getDeclaringClass());
+               sm.setWithinType(aType);
                return sm;
        }
 
-       public ShadowMatch matchesInitialization(Constructor aConstructor) {
-               Shadow s = ReflectionShadow.makeInitializationShadow(world, aConstructor, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(aConstructor);
-               sm.setWithinCode(null);
-               sm.setWithinType(aConstructor.getDeclaringClass());
-               return sm;
-       }
-
-       public ShadowMatch matchesPreInitialization(Constructor aConstructor) {
-               Shadow s = ReflectionShadow.makePreInitializationShadow(world, aConstructor, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(aConstructor);
-               sm.setWithinCode(null);
-               sm.setWithinType(aConstructor.getDeclaringClass());
-               return sm;
-       }
-
-       public ShadowMatch matchesMethodCall(Method aMethod, Member withinCode) {
-               Shadow s = ReflectionShadow.makeCallShadow(world, aMethod, withinCode, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
+       // public ShadowMatch matchesAdviceExecution(Method aMethod) {
+       // Shadow s = ReflectionShadow.makeAdviceExecutionShadow(world, aMethod, this.matchContext);
+       // StandardShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(aMethod);
+       // sm.setWithinCode(null);
+       // sm.setWithinType(aMethod.getDeclaringClass());
+       // return sm;
+       // }
+       //
+       // public ShadowMatch matchesInitialization(Constructor aConstructor) {
+       // Shadow s = ReflectionShadow.makeInitializationShadow(world, aConstructor, this.matchContext);
+       // StandardShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(aConstructor);
+       // sm.setWithinCode(null);
+       // sm.setWithinType(aConstructor.getDeclaringClass());
+       // return sm;
+       // }
+       //
+       // public ShadowMatch matchesPreInitialization(Constructor aConstructor) {
+       // Shadow s = ReflectionShadow.makePreInitializationShadow(world, aConstructor, this.matchContext);
+       // StandardShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(aConstructor);
+       // sm.setWithinCode(null);
+       // sm.setWithinType(aConstructor.getDeclaringClass());
+       // return sm;
+       // }
+       //
+       public ShadowMatch matchesMethodCall(ResolvedMember aMethod, ResolvedMember withinCode) {
+               Shadow s = StandardShadow.makeCallShadow(world, aMethod, withinCode, this.matchContext);
+               StandardShadowMatchImpl sm = getShadowMatch(s);
                sm.setSubject(aMethod);
                sm.setWithinCode(withinCode);
-               sm.setWithinType(withinCode.getDeclaringClass());
-               return sm;
-       }
-
-       public ShadowMatch matchesMethodCall(Method aMethod, Class callerType) {
-               Shadow s = ReflectionShadow.makeCallShadow(world, aMethod, callerType, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(aMethod);
-               sm.setWithinCode(null);
-               sm.setWithinType(callerType);
-               return sm;
-       }
-
-       public ShadowMatch matchesConstructorCall(Constructor aConstructor, Class callerType) {
-               Shadow s = ReflectionShadow.makeCallShadow(world, aConstructor, callerType, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(aConstructor);
-               sm.setWithinCode(null);
-               sm.setWithinType(callerType);
-               return sm;
-       }
-
-       public ShadowMatch matchesConstructorCall(Constructor aConstructor, Member withinCode) {
-               Shadow s = ReflectionShadow.makeCallShadow(world, aConstructor, withinCode, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(aConstructor);
-               sm.setWithinCode(withinCode);
-               sm.setWithinType(withinCode.getDeclaringClass());
-               return sm;
-       }
-
-       public ShadowMatch matchesHandler(Class exceptionType, Class handlingType) {
-               Shadow s = ReflectionShadow.makeHandlerShadow(world, exceptionType, handlingType, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(null);
-               sm.setWithinCode(null);
-               sm.setWithinType(handlingType);
-               return sm;
-       }
-
-       public ShadowMatch matchesHandler(Class exceptionType, Member withinCode) {
-               Shadow s = ReflectionShadow.makeHandlerShadow(world, exceptionType, withinCode, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(null);
-               sm.setWithinCode(withinCode);
-               sm.setWithinType(withinCode.getDeclaringClass());
-               return sm;
-       }
-
-       public ShadowMatch matchesFieldGet(Field aField, Class withinType) {
-               Shadow s = ReflectionShadow.makeFieldGetShadow(world, aField, withinType, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(aField);
-               sm.setWithinCode(null);
-               sm.setWithinType(withinType);
-               return sm;
-       }
-
-       public ShadowMatch matchesFieldGet(Field aField, Member withinCode) {
-               Shadow s = ReflectionShadow.makeFieldGetShadow(world, aField, withinCode, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(aField);
-               sm.setWithinCode(withinCode);
-               sm.setWithinType(withinCode.getDeclaringClass());
-               return sm;
-       }
-
-       public ShadowMatch matchesFieldSet(Field aField, Class withinType) {
-               Shadow s = ReflectionShadow.makeFieldSetShadow(world, aField, withinType, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(aField);
-               sm.setWithinCode(null);
-               sm.setWithinType(withinType);
-               return sm;
-       }
-
-       public ShadowMatch matchesFieldSet(Field aField, Member withinCode) {
-               Shadow s = ReflectionShadow.makeFieldSetShadow(world, aField, withinCode, this.matchContext);
-               ShadowMatchImpl sm = getShadowMatch(s);
-               sm.setSubject(aField);
-               sm.setWithinCode(withinCode);
-               sm.setWithinType(withinCode.getDeclaringClass());
+               sm.setWithinType((ResolvedType) withinCode.getDeclaringType());
                return sm;
        }
 
-       private ShadowMatchImpl getShadowMatch(Shadow forShadow) {
+       //
+       // public ShadowMatch matchesMethodCall(Method aMethod, Class callerType) {
+       // Shadow s = ReflectionShadow.makeCallShadow(world, aMethod, callerType, this.matchContext);
+       // ShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(aMethod);
+       // sm.setWithinCode(null);
+       // sm.setWithinType(callerType);
+       // return sm;
+       // }
+       //
+       // public ShadowMatch matchesConstructorCall(Constructor aConstructor, Class callerType) {
+       // Shadow s = ReflectionShadow.makeCallShadow(world, aConstructor, callerType, this.matchContext);
+       // ShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(aConstructor);
+       // sm.setWithinCode(null);
+       // sm.setWithinType(callerType);
+       // return sm;
+       // }
+       //
+       // public ShadowMatch matchesConstructorCall(Constructor aConstructor, Member withinCode) {
+       // Shadow s = ReflectionShadow.makeCallShadow(world, aConstructor, withinCode, this.matchContext);
+       // ShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(aConstructor);
+       // sm.setWithinCode(withinCode);
+       // sm.setWithinType(withinCode.getDeclaringClass());
+       // return sm;
+       // }
+       //
+       // public ShadowMatch matchesHandler(Class exceptionType, Class handlingType) {
+       // Shadow s = ReflectionShadow.makeHandlerShadow(world, exceptionType, handlingType, this.matchContext);
+       // ShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(null);
+       // sm.setWithinCode(null);
+       // sm.setWithinType(handlingType);
+       // return sm;
+       // }
+       //
+       // public ShadowMatch matchesHandler(Class exceptionType, Member withinCode) {
+       // Shadow s = ReflectionShadow.makeHandlerShadow(world, exceptionType, withinCode, this.matchContext);
+       // ShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(null);
+       // sm.setWithinCode(withinCode);
+       // sm.setWithinType(withinCode.getDeclaringClass());
+       // return sm;
+       // }
+       //
+       // public ShadowMatch matchesFieldGet(Field aField, Class withinType) {
+       // Shadow s = ReflectionShadow.makeFieldGetShadow(world, aField, withinType, this.matchContext);
+       // ShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(aField);
+       // sm.setWithinCode(null);
+       // sm.setWithinType(withinType);
+       // return sm;
+       // }
+       //
+       // public ShadowMatch matchesFieldGet(Field aField, Member withinCode) {
+       // Shadow s = ReflectionShadow.makeFieldGetShadow(world, aField, withinCode, this.matchContext);
+       // ShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(aField);
+       // sm.setWithinCode(withinCode);
+       // sm.setWithinType(withinCode.getDeclaringClass());
+       // return sm;
+       // }
+       //
+       // public ShadowMatch matchesFieldSet(Field aField, Class withinType) {
+       // Shadow s = ReflectionShadow.makeFieldSetShadow(world, aField, withinType, this.matchContext);
+       // ShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(aField);
+       // sm.setWithinCode(null);
+       // sm.setWithinType(withinType);
+       // return sm;
+       // }
+       //
+       // public ShadowMatch matchesFieldSet(Field aField, Member withinCode) {
+       // Shadow s = ReflectionShadow.makeFieldSetShadow(world, aField, withinCode, this.matchContext);
+       // StandardShadowMatchImpl sm = getShadowMatch(s);
+       // sm.setSubject(aField);
+       // sm.setWithinCode(withinCode);
+       // sm.setWithinType(withinCode.getDeclaringClass());
+       // return sm;
+       // }
+
+       private StandardShadowMatchImpl getShadowMatch(Shadow forShadow) {
                org.aspectj.util.FuzzyBoolean match = pointcut.match(forShadow);
                Test residueTest = Literal.TRUE;
                ExposedState state = getExposedState();
                if (match.maybeTrue()) {
                        residueTest = pointcut.findResidue(forShadow, state);
                }
-               ShadowMatchImpl sm = new ShadowMatchImpl(match, residueTest, state, parameters);
+               StandardShadowMatchImpl sm = new StandardShadowMatchImpl(match, residueTest, state, parameters);
                sm.setMatchingContext(this.matchContext);
                return sm;
        }
index 8e741b6c94a5cd5f463fa97fd19ef8a6cc54331e..411ccdd91c8bbe950666bce4f0ac1e60d1aa22e4 100644 (file)
@@ -71,14 +71,15 @@ public class StandardShadow extends Shadow {
                return new StandardShadow(inWorld, kind, signature, null, enclosingType, null, withContext);
        }
 
-       public static Shadow makeCallShadow(World inWorld, java.lang.reflect.Member aMember, java.lang.reflect.Member withinCode,
+       public static Shadow makeCallShadow(World inWorld, ResolvedMember aMember, ResolvedMember withinCode,
                        MatchingContext withContext) {
                Shadow enclosingShadow = makeExecutionShadow(inWorld, withinCode, withContext);
-               Member signature = ReflectionBasedReferenceTypeDelegateFactory.createResolvedMember(aMember, inWorld);
-               ResolvedMember enclosingMember = ReflectionBasedReferenceTypeDelegateFactory.createResolvedMember(withinCode, inWorld);
-               ResolvedType enclosingType = enclosingMember.getDeclaringType().resolve(inWorld);
-               Kind kind = aMember instanceof Method ? Shadow.MethodCall : Shadow.ConstructorCall;
-               return new StandardShadow(inWorld, kind, signature, enclosingShadow, enclosingType, enclosingMember, withContext);
+               // Member signature = ReflectionBasedReferenceTypeDelegateFactory.createResolvedMember(aMember, inWorld);
+               // ResolvedMember enclosingMember = ReflectionBasedReferenceTypeDelegateFactory.createResolvedMember(withinCode, inWorld);
+               // ResolvedType enclosingType = enclosingMember.getDeclaringType().resolve(inWorld);
+               Kind kind = !aMember.getName().equals("<init>") ? Shadow.MethodCall : Shadow.ConstructorCall;
+               return new StandardShadow(inWorld, kind, aMember, enclosingShadow, (ResolvedType) withinCode.getDeclaringType(),
+                               withinCode, withContext);
        }
 
        public static Shadow makeCallShadow(World inWorld, java.lang.reflect.Member aMember, Class thisClass,
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/reflect/StandardShadowMatchImpl.java b/org.aspectj.matcher/src/org/aspectj/weaver/reflect/StandardShadowMatchImpl.java
new file mode 100644 (file)
index 0000000..baeab03
--- /dev/null
@@ -0,0 +1,196 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver.reflect;
+
+import org.aspectj.util.FuzzyBoolean;
+import org.aspectj.weaver.ResolvedMember;
+import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.ast.And;
+import org.aspectj.weaver.ast.Call;
+import org.aspectj.weaver.ast.FieldGetCall;
+import org.aspectj.weaver.ast.HasAnnotation;
+import org.aspectj.weaver.ast.ITestVisitor;
+import org.aspectj.weaver.ast.Instanceof;
+import org.aspectj.weaver.ast.Literal;
+import org.aspectj.weaver.ast.Not;
+import org.aspectj.weaver.ast.Or;
+import org.aspectj.weaver.ast.Test;
+import org.aspectj.weaver.internal.tools.MatchingContextBasedTest;
+import org.aspectj.weaver.patterns.ExposedState;
+import org.aspectj.weaver.tools.DefaultMatchingContext;
+import org.aspectj.weaver.tools.JoinPointMatch;
+import org.aspectj.weaver.tools.MatchingContext;
+import org.aspectj.weaver.tools.PointcutParameter;
+import org.aspectj.weaver.tools.ShadowMatch;
+
+/**
+ * @author colyer Implementation of ShadowMatch for reflection based worlds.
+ */
+public class StandardShadowMatchImpl implements ShadowMatch {
+
+       private FuzzyBoolean match;
+       private ExposedState state;
+       private Test residualTest;
+       private PointcutParameter[] params;
+       private ResolvedMember withinCode;
+       private ResolvedMember subject;
+       private ResolvedType withinType;
+       private MatchingContext matchContext = new DefaultMatchingContext();
+
+       public StandardShadowMatchImpl(FuzzyBoolean match, Test test, ExposedState state, PointcutParameter[] params) {
+               this.match = match;
+               this.residualTest = test;
+               this.state = state;
+               this.params = params;
+       }
+
+       public void setWithinCode(ResolvedMember aMember) {
+               this.withinCode = aMember;
+       }
+
+       public void setSubject(ResolvedMember aMember) {
+               this.subject = aMember;
+       }
+
+       public void setWithinType(ResolvedType aClass) {
+               this.withinType = aClass;
+       }
+
+       public boolean alwaysMatches() {
+               return match.alwaysTrue();
+       }
+
+       public boolean maybeMatches() {
+               return match.maybeTrue();
+       }
+
+       public boolean neverMatches() {
+               return match.alwaysFalse();
+       }
+
+       public JoinPointMatch matchesJoinPoint(Object thisObject, Object targetObject, Object[] args) {
+               if (neverMatches())
+                       return JoinPointMatchImpl.NO_MATCH;
+               if (new RuntimeTestEvaluator(residualTest, thisObject, targetObject, args, this.matchContext).matches()) {
+                       return new JoinPointMatchImpl(getPointcutParameters(thisObject, targetObject, args));
+               } else {
+                       return JoinPointMatchImpl.NO_MATCH;
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.aspectj.weaver.tools.ShadowMatch#setMatchingContext(org.aspectj.weaver.tools.MatchingContext)
+        */
+       public void setMatchingContext(MatchingContext aMatchContext) {
+               this.matchContext = aMatchContext;
+       }
+
+       private PointcutParameter[] getPointcutParameters(Object thisObject, Object targetObject, Object[] args) {
+               // Var[] vars = state.vars;
+               // PointcutParameterImpl[] bindings = new PointcutParameterImpl[params.length];
+               // for (int i = 0; i < bindings.length; i++) {
+               // bindings[i] = new PointcutParameterImpl(params[i].getName(), params[i].getType());
+               // bindings[i].setBinding(((ReflectionVar) vars[i]).getBindingAtJoinPoint(thisObject, targetObject, args, subject,
+               // withinCode, withinType));
+               // }
+               // return bindings;
+               return null;
+       }
+
+       private static class RuntimeTestEvaluator implements ITestVisitor {
+
+               private boolean matches = true;
+               private final Test test;
+               private final Object thisObject;
+               private final Object targetObject;
+               private final Object[] args;
+               private final MatchingContext matchContext;
+
+               public RuntimeTestEvaluator(Test aTest, Object thisObject, Object targetObject, Object[] args, MatchingContext context) {
+                       this.test = aTest;
+                       this.thisObject = thisObject;
+                       this.targetObject = targetObject;
+                       this.args = args;
+                       this.matchContext = context;
+               }
+
+               public boolean matches() {
+                       test.accept(this);
+                       return matches;
+               }
+
+               public void visit(And e) {
+                       boolean leftMatches = new RuntimeTestEvaluator(e.getLeft(), thisObject, targetObject, args, matchContext).matches();
+                       if (!leftMatches) {
+                               matches = false;
+                       } else {
+                               matches = new RuntimeTestEvaluator(e.getRight(), thisObject, targetObject, args, matchContext).matches();
+                       }
+               }
+
+               public void visit(Instanceof i) {
+                       ReflectionVar v = (ReflectionVar) i.getVar();
+                       Object value = v.getBindingAtJoinPoint(thisObject, targetObject, args);
+                       World world = v.getType().getWorld();
+                       ResolvedType desiredType = i.getType().resolve(world);
+                       ResolvedType actualType = world.resolve(value.getClass().getName());
+                       matches = desiredType.isAssignableFrom(actualType);
+               }
+
+               public void visit(MatchingContextBasedTest matchingContextTest) {
+                       matches = matchingContextTest.matches(this.matchContext);
+               }
+
+               public void visit(Not not) {
+                       matches = !new RuntimeTestEvaluator(not.getBody(), thisObject, targetObject, args, matchContext).matches();
+               }
+
+               public void visit(Or or) {
+                       boolean leftMatches = new RuntimeTestEvaluator(or.getLeft(), thisObject, targetObject, args, matchContext).matches();
+                       if (leftMatches) {
+                               matches = true;
+                       } else {
+                               matches = new RuntimeTestEvaluator(or.getRight(), thisObject, targetObject, args, matchContext).matches();
+                       }
+               }
+
+               public void visit(Literal literal) {
+                       if (literal == Literal.FALSE) {
+                               matches = false;
+                       } else {
+                               matches = true;
+                       }
+               }
+
+               public void visit(Call call) {
+                       throw new UnsupportedOperationException("Can't evaluate call test at runtime");
+               }
+
+               public void visit(FieldGetCall fieldGetCall) {
+                       throw new UnsupportedOperationException("Can't evaluate fieldGetCall test at runtime");
+               }
+
+               public void visit(HasAnnotation hasAnnotation) {
+                       ReflectionVar v = (ReflectionVar) hasAnnotation.getVar();
+                       Object value = v.getBindingAtJoinPoint(thisObject, targetObject, args);
+                       World world = v.getType().getWorld();
+                       ResolvedType actualVarType = world.resolve(value.getClass().getName());
+                       ResolvedType requiredAnnotationType = hasAnnotation.getAnnotationType().resolve(world);
+                       matches = actualVarType.hasAnnotation(requiredAnnotationType);
+               }
+
+       }
+
+}
index 3d553494430a680ce55adcbb16dd7227bbef93d5..63d908bd28f2789fbd80241cefa5e4963d7ee2bf 100644 (file)
 
 package org.aspectj.weaver.tools;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-
 import org.aspectj.weaver.ResolvedMember;
 import org.aspectj.weaver.ResolvedType;
 
@@ -44,15 +39,6 @@ public interface StandardPointcutExpression {
         */
        boolean mayNeedDynamicTest();
 
-       /**
-        * Determine whether or not this pointcut matches the execution of a given method.
-        * 
-        * @param aMethod the method being executed
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing the
-        *         execution of the method.
-        */
-       ShadowMatch matchesMethodExecution(Method aMethod);
-
        /**
         * Determine whether or not this pointcut matches the execution of a given method.
         * 
@@ -62,15 +48,15 @@ public interface StandardPointcutExpression {
         */
        ShadowMatch matchesMethodExecution(ResolvedMember aMethod);
 
-       /**
-        * Determine whether or not this pointcut matches the execution of a given constructor.
-        * 
-        * @param aConstructor the constructor being executed
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing the
-        *         execution of the constructor.
-        */
-       ShadowMatch matchesConstructorExecution(Constructor aConstructor);
-
+       // /**
+       // * Determine whether or not this pointcut matches the execution of a given constructor.
+       // *
+       // * @param aConstructor the constructor being executed
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing the
+       // * execution of the constructor.
+       // */
+       // ShadowMatch matchesConstructorExecution(Constructor aConstructor);
+       //
        /**
         * Determine whether or not this pointcut matches the static initialization of the given class.
         * 
@@ -78,45 +64,48 @@ public interface StandardPointcutExpression {
         * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matchs join points representing the static
         *         initialization of the given type
         */
-       ShadowMatch matchesStaticInitialization(Class aClass);
-
-       /**
-        * Determine whether or not this pointcut matches the static initialization of the given class.
-        * 
-        * @param aClass the class being statically initialized
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matchs join points representing the static
-        *         initialization of the given type
-        */
-       ShadowMatch matchesStaticInitialization(ResolvedType type);
-
-       /**
-        * Determine whether or not this pointcut matches the execution of a given piece of advice.
-        * 
-        * @param anAdviceMethod a method representing the advice being executed
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing the
-        *         execution of the advice.
-        */
-       ShadowMatch matchesAdviceExecution(Method anAdviceMethod);
-
-       /**
-        * Determine whether or not this pointcut matches the initialization of an object initiated by a call to the given constructor.
-        * 
-        * @param aConstructor the constructor initiating the initialization
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing
-        *         initialization via the given constructor.
-        */
-       ShadowMatch matchesInitialization(Constructor aConstructor);
-
-       /**
-        * Determine whether or not this pointcut matches the pre-initialization of an object initiated by a call to the given
-        * constructor.
-        * 
-        * @param aConstructor the constructor initiating the initialization
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing
-        *         pre-initialization via the given constructor.
-        */
-       ShadowMatch matchesPreInitialization(Constructor aConstructor);
-
+       ShadowMatch matchesStaticInitialization(ResolvedType aType);
+
+       //
+       // /**
+       // * Determine whether or not this pointcut matches the static initialization of the given class.
+       // *
+       // * @param aClass the class being statically initialized
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matchs join points representing the
+       // static
+       // * initialization of the given type
+       // */
+       // ShadowMatch matchesStaticInitialization(ResolvedType type);
+       //
+       // /**
+       // * Determine whether or not this pointcut matches the execution of a given piece of advice.
+       // *
+       // * @param anAdviceMethod a method representing the advice being executed
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing the
+       // * execution of the advice.
+       // */
+       // ShadowMatch matchesAdviceExecution(Method anAdviceMethod);
+       //
+       // /**
+       // * Determine whether or not this pointcut matches the initialization of an object initiated by a call to the given
+       // constructor.
+       // *
+       // * @param aConstructor the constructor initiating the initialization
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing
+       // * initialization via the given constructor.
+       // */
+       // ShadowMatch matchesInitialization(Constructor aConstructor);
+       //
+       // /**
+       // * Determine whether or not this pointcut matches the pre-initialization of an object initiated by a call to the given
+       // * constructor.
+       // *
+       // * @param aConstructor the constructor initiating the initialization
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing
+       // * pre-initialization via the given constructor.
+       // */
+       // ShadowMatch matchesPreInitialization(Constructor aConstructor);
+       //
        /**
         * Determine whether or not this pointcut matches a method call to the given method, made during the execution of the given
         * method or constructor.
@@ -126,105 +115,116 @@ public interface StandardPointcutExpression {
         * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing a call to
         *         this method during the execution of the given member.
         */
-       ShadowMatch matchesMethodCall(Method aMethod, Member withinCode);
-
-       /**
-        * Determine whether or not this pointcut matches a method call to the given method, made outside of the scope of any method or
-        * constructor, but within the callerType (for example, during static initialization of the type).
-        * 
-        * @param aMethod the method being called
-        * @param callerType the declared type of the caller
-        * @param receiverType the declared type of the recipient of the call
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing a call to
-        *         this method during the execution of the given member.
-        */
-       ShadowMatch matchesMethodCall(Method aMethod, Class callerType);
-
-       /**
-        * Determine whether or not this pointcut matches a method call to the given constructor, made during the execution of the given
-        * method or constructor.
-        * 
-        * @param aConstructor the constructor being called
-        * @param withinCode the Method or Constructor from within which the call is made
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing a call to
-        *         this constructor during the execution of the given member.
-        */
-       ShadowMatch matchesConstructorCall(Constructor aConstructor, Member withinCode);
-
-       /**
-        * Determine whether or not this pointcut matches a method call to the given constructor, made outside of the scope of any
-        * method or constructor, but within the callerType.
-        * 
-        * @param aConstructor the cosstructor being called
-        * @param callerType the declared type of the caller
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing a call to
-        *         this constructor during the execution of the given member.
-        */
-       ShadowMatch matchesConstructorCall(Constructor aConstructor, Class callerType);
-
-       /**
-        * Determine whether or not this pointcut matches the execution of a given exception handler within the given method or
-        * constructor
-        * 
-        * @param exceptionType the static type of the exception being handled
-        * @param withinCode the method or constructor in which the catch block is declared
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing the
-        *         handling of the given exception
-        */
-       ShadowMatch matchesHandler(Class exceptionType, Member withinCode);
-
-       /**
-        * Determine whether or not this pointcut matches the execution of a given exception handler outside of the scope of any method
-        * or constructor, but within the handling type.
-        * 
-        * @param exceptionType the static type of the exception being handled
-        * @param handlingType the type in which the handler block is executing
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing the
-        *         handling of the given exception
-        */
-       ShadowMatch matchesHandler(Class exceptionType, Class handlingType);
-
-       /**
-        * Determine whether or not this pointcut matches a set of the given field from within the given method or constructor.
-        * 
-        * @param aField the field being updated
-        * @param withinCode the Method or Constructor owning the call site
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches field set join points for the given
-        *         field and call site.
-        */
-       ShadowMatch matchesFieldSet(Field aField, Member withinCode);
-
-       /**
-        * Determine whether or not this pointcut matches a set of the given field outside of the scope of any method or constructor,
-        * but within the given type (for example, during static initialization).
-        * 
-        * @param aField the field being updated
-        * @param withinType the type owning the call site
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches field set join points for the given
-        *         field and call site.
-        */
-       ShadowMatch matchesFieldSet(Field aField, Class withinType);
-
-       /**
-        * Determine whether or not this pointcut matches a get of the given field from within the given method or constructor.
-        * 
-        * @param aField the field being updated
-        * @param withinCode the Method or Constructor owning the call site
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches field get join points for the given
-        *         field and call site.
-        */
-       ShadowMatch matchesFieldGet(Field aField, Member withinCode);
-
-       /**
-        * Determine whether or not this pointcut matches a get of the given field outside of the scope of any method or constructor,
-        * but within the given type (for example, during static initialization).
-        * 
-        * @param aField the field being accessed
-        * @param withinType the type owning the call site
-        * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches field get join points for the given
-        *         field and call site.
-        */
-       ShadowMatch matchesFieldGet(Field aField, Class withinType);
+       ShadowMatch matchesMethodCall(ResolvedMember aMethod, ResolvedMember withinCode);
+
+       //
+       // /**
+       // * Determine whether or not this pointcut matches a method call to the given method, made outside of the scope of any method
+       // or
+       // * constructor, but within the callerType (for example, during static initialization of the type).
+       // *
+       // * @param aMethod the method being called
+       // * @param callerType the declared type of the caller
+       // * @param receiverType the declared type of the recipient of the call
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing a call
+       // to
+       // * this method during the execution of the given member.
+       // */
+       // ShadowMatch matchesMethodCall(Method aMethod, Class callerType);
+       //
+       // /**
+       // * Determine whether or not this pointcut matches a method call to the given constructor, made during the execution of the
+       // given
+       // * method or constructor.
+       // *
+       // * @param aConstructor the constructor being called
+       // * @param withinCode the Method or Constructor from within which the call is made
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing a call
+       // to
+       // * this constructor during the execution of the given member.
+       // */
+       // ShadowMatch matchesConstructorCall(Constructor aConstructor, Member withinCode);
+       //
+       // /**
+       // * Determine whether or not this pointcut matches a method call to the given constructor, made outside of the scope of any
+       // * method or constructor, but within the callerType.
+       // *
+       // * @param aConstructor the cosstructor being called
+       // * @param callerType the declared type of the caller
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing a call
+       // to
+       // * this constructor during the execution of the given member.
+       // */
+       // ShadowMatch matchesConstructorCall(Constructor aConstructor, Class callerType);
+       //
+       // /**
+       // * Determine whether or not this pointcut matches the execution of a given exception handler within the given method or
+       // * constructor
+       // *
+       // * @param exceptionType the static type of the exception being handled
+       // * @param withinCode the method or constructor in which the catch block is declared
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing the
+       // * handling of the given exception
+       // */
+       // ShadowMatch matchesHandler(Class exceptionType, Member withinCode);
+       //
+       // /**
+       // * Determine whether or not this pointcut matches the execution of a given exception handler outside of the scope of any
+       // method
+       // * or constructor, but within the handling type.
+       // *
+       // * @param exceptionType the static type of the exception being handled
+       // * @param handlingType the type in which the handler block is executing
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches join points representing the
+       // * handling of the given exception
+       // */
+       // ShadowMatch matchesHandler(Class exceptionType, Class handlingType);
+       //
+       // /**
+       // * Determine whether or not this pointcut matches a set of the given field from within the given method or constructor.
+       // *
+       // * @param aField the field being updated
+       // * @param withinCode the Method or Constructor owning the call site
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches field set join points for the
+       // given
+       // * field and call site.
+       // */
+       // ShadowMatch matchesFieldSet(Field aField, Member withinCode);
+       //
+       // /**
+       // * Determine whether or not this pointcut matches a set of the given field outside of the scope of any method or constructor,
+       // * but within the given type (for example, during static initialization).
+       // *
+       // * @param aField the field being updated
+       // * @param withinType the type owning the call site
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches field set join points for the
+       // given
+       // * field and call site.
+       // */
+       // ShadowMatch matchesFieldSet(Field aField, Class withinType);
+       //
+       // /**
+       // * Determine whether or not this pointcut matches a get of the given field from within the given method or constructor.
+       // *
+       // * @param aField the field being updated
+       // * @param withinCode the Method or Constructor owning the call site
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches field get join points for the
+       // given
+       // * field and call site.
+       // */
+       // ShadowMatch matchesFieldGet(Field aField, Member withinCode);
+       //
+       // /**
+       // * Determine whether or not this pointcut matches a get of the given field outside of the scope of any method or constructor,
+       // * but within the given type (for example, during static initialization).
+       // *
+       // * @param aField the field being accessed
+       // * @param withinType the type owning the call site
+       // * @return a ShadowMatch indicating whether the pointcut always, sometimes, or never matches field get join points for the
+       // given
+       // * field and call site.
+       // */
+       // ShadowMatch matchesFieldGet(Field aField, Class withinType);
 
        /**
         * Return a string representation of this pointcut expression.
index 26e0e0b5c5689729a1b83123c48dd3c7330c9454..c67fe348f867624eec78dc1f9ee5f577581b7121 100644 (file)
@@ -16,13 +16,14 @@ import org.aspectj.weaver.ResolvedMember;
 import org.aspectj.weaver.ResolvedType;
 import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.World;
+import org.aspectj.weaver.tools.ShadowMatch;
 import org.aspectj.weaver.tools.StandardPointcutExpression;
 import org.aspectj.weaver.tools.StandardPointcutParser;
 
 /**
  * Test the use of the pointcut parser and matching infrastructure. The org.aspectj.matcher.tools infrastructure used should not be
  * aware of what kind of World it is working with and only operate in terms of the type abstraction expressed in the
- * org.aspectj.matcher project (so Members, etc).
+ * org.aspectj.matcher project (so Members, etc). These tests only use base java types, there is no other testdata.
  * 
  * This is based on the Reflection oriented PointcutExpressionTest in the weaver project.
  * 
@@ -41,6 +42,8 @@ public abstract class CommonPointcutExpressionTests extends TestCase {
                pointcutParser = StandardPointcutParser.getPointcutParserSupportingAllPrimitives(world);
        }
 
+       // -- some very basic stuff, if these don't pass it isn't worth continuing
+
        public void testResolvingOneType() {
                // do it via name
                ResolvedType type = world.resolve("java.lang.String");
@@ -57,6 +60,8 @@ public abstract class CommonPointcutExpressionTests extends TestCase {
                assertNotNull(method);
        }
 
+       // -- next few tests relate to matching different pointcut expressions against a method-execution join point
+
        public void testMethodExecutionMatching01() {
                checkAlwaysMatches("execution(String valueOf(boolean))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
        }
@@ -80,55 +85,133 @@ public abstract class CommonPointcutExpressionTests extends TestCase {
                checkAlwaysMatches("execution(*b*[] *())", "java.util.List", "toArray", "()[Ljava/lang/Object;");
        }
 
-       // ---
+       public void testMatchingThis01() {
+               StandardPointcutExpression ex = pointcutParser.parsePointcutExpression("this(java.lang.String)");
+               ResolvedType jlString = world.resolve("java.lang.String");
+               ResolvedType juList = world.resolve("java.util.List");
 
-       public void testMethodMatchesStaticInitialization() {
-               StandardPointcutExpression ex = pointcutParser.parsePointcutExpression("staticinitialization(java.lang.String)");
-               assertNotNull(ex);
+               // regular method
+               ShadowMatch shadowMatch = ex.matchesMethodExecution(getMethod(jlString, "toLowerCase", "()Ljava/lang/String;"));
+               assertTrue(shadowMatch.alwaysMatches());
 
+               // static method
+               shadowMatch = ex.matchesMethodExecution(getMethod(jlString, "valueOf", "(Z)Ljava/lang/String;"));
+               assertTrue(shadowMatch.neverMatches());
+
+               // maybe match: this could be an ArrayList when clear() is called
+               ex = pointcutParser.parsePointcutExpression("this(java.util.ArrayList)");
+               shadowMatch = ex.matchesMethodExecution(getMethod(juList, "clear", "()V"));
+               assertTrue(shadowMatch.maybeMatches());
+               assertFalse(shadowMatch.neverMatches());
+               assertFalse(shadowMatch.alwaysMatches());
+       }
+
+       public void testMatchingTarget01() {
+               StandardPointcutExpression ex = pointcutParser.parsePointcutExpression("target(java.lang.String)");
                ResolvedType jlString = world.resolve("java.lang.String");
+               ResolvedType juList = world.resolve("java.util.List");
 
-               boolean b = ex.matchesStaticInitialization(jlString).alwaysMatches();
-               assertTrue(b);
+               // regular method
+               ShadowMatch shadowMatch = ex.matchesMethodExecution(getMethod(jlString, "toLowerCase", "()Ljava/lang/String;"));
+               assertTrue(shadowMatch.alwaysMatches());
+
+               // static method
+               shadowMatch = ex.matchesMethodExecution(getMethod(jlString, "valueOf", "(Z)Ljava/lang/String;"));
+               assertTrue(shadowMatch.neverMatches());
+
+               // maybe match: target could be an ArrayList when clear() is called
+               ex = pointcutParser.parsePointcutExpression("target(java.util.ArrayList)");
+               shadowMatch = ex.matchesMethodExecution(getMethod(juList, "clear", "()V"));
+               assertTrue(shadowMatch.maybeMatches());
+               assertFalse(shadowMatch.neverMatches());
+               assertFalse(shadowMatch.alwaysMatches());
+       }
+
+       public void testMatchingArgs01() {
+               StandardPointcutExpression ex = pointcutParser.parsePointcutExpression("args(..,int)");
+               ResolvedType jlString = world.resolve("java.lang.String");
+               ResolvedType juList = world.resolve("java.util.List");
+
+               ResolvedMember stringSplitMethod = getMethod(jlString, "split", "(Ljava/lang/String;I)[Ljava/lang/String;");
+               ResolvedMember stringValueOfIntMethod = getMethod(jlString, "valueOf", "(I)Ljava/lang/String;");
+               ResolvedMember stringValueOfLongMethod = getMethod(jlString, "valueOf", "(J)Ljava/lang/String;");
+
+               ShadowMatch shadowMatch = ex.matchesMethodExecution(stringSplitMethod);
+               assertTrue(shadowMatch.alwaysMatches());
+
+               shadowMatch = ex.matchesMethodExecution(stringValueOfIntMethod);
+               assertTrue(shadowMatch.alwaysMatches());
+
+               shadowMatch = ex.matchesMethodExecution(stringValueOfLongMethod);
+               assertTrue(shadowMatch.neverMatches());
+
+               // at List.add(Object) the Object might be a String
+               ex = pointcutParser.parsePointcutExpression("args(java.lang.String)");
+               shadowMatch = ex.matchesMethodExecution(getMethod(juList, "add", "(Ljava/lang/Object;)Z"));
+               assertTrue(shadowMatch.maybeMatches());
+       }
+
+       public void testMatchingWithin01() {
+               StandardPointcutExpression ex = pointcutParser.parsePointcutExpression("within(java.lang.String)");
+               ResolvedType jlString = world.resolve("java.lang.String");
+               ResolvedType juList = world.resolve("java.util.List");
+
+               ResolvedMember stringSplitMethod = getMethod(jlString, "split", "(Ljava/lang/String;I)[Ljava/lang/String;");
+               ResolvedMember stringValueOfIntMethod = getMethod(jlString, "valueOf", "(I)Ljava/lang/String;");
+               ResolvedMember listAddMethod = getMethod(juList, "add", "(Ljava/lang/Object;)Z");
+
+               assertTrue(ex.matchesMethodExecution(stringSplitMethod).alwaysMatches());
+               assertTrue(ex.matchesMethodExecution(stringValueOfIntMethod).alwaysMatches());
+               assertTrue(ex.matchesMethodExecution(listAddMethod).neverMatches());
+       }
+
+       public void testMatchingWithinCode01() {
+               StandardPointcutExpression ex = pointcutParser.parsePointcutExpression("withincode(* *..String.*(..))");
+               ResolvedType jlString = world.resolve("java.lang.String");
+               ResolvedType juList = world.resolve("java.util.List");
+
+               ResolvedMember stringSplitMethod = getMethod(jlString, "split", "(Ljava/lang/String;I)[Ljava/lang/String;");
+               ResolvedMember stringValueOfIntMethod = getMethod(jlString, "valueOf", "(I)Ljava/lang/String;");
+               ResolvedMember listAddMethod = getMethod(juList, "add", "(Ljava/lang/Object;)Z");
+
+               assertTrue(ex.matchesMethodExecution(stringSplitMethod).neverMatches());
+               assertTrue(ex.matchesMethodExecution(stringValueOfIntMethod).neverMatches());
+               assertTrue(ex.matchesMethodExecution(listAddMethod).neverMatches());
+       }
+
+       // -- next few tests relate to matching different pointcut expressions against a method-call join point
+
+       public void testCallMatchesMethodCall() {
+               StandardPointcutExpression ex = pointcutParser.parsePointcutExpression("call(* *..String.*(..))");
+               ResolvedType jlString = world.resolve("java.lang.String");
+               ResolvedType juList = world.resolve("java.util.List");
+
+               ResolvedMember stringSplitMethod = getMethod(jlString, "split", "(Ljava/lang/String;I)[Ljava/lang/String;");
+               ResolvedMember stringValueOfIntMethod = getMethod(jlString, "valueOf", "(I)Ljava/lang/String;");
+               ResolvedMember listAddMethod = getMethod(juList, "add", "(Ljava/lang/Object;)Z");
+
+               // call from list to string, should be OK
+               assertTrue(ex.matchesMethodCall(stringSplitMethod, listAddMethod).alwaysMatches());
+               assertTrue(ex.matchesMethodCall(stringValueOfIntMethod, listAddMethod).alwaysMatches());
+               assertTrue(ex.matchesMethodCall(listAddMethod, stringSplitMethod).neverMatches());
+
+               ex = pointcutParser.parsePointcutExpression("call(* *..ArrayList.*(..))");
+               assertTrue(ex.matchesMethodCall(listAddMethod, stringSplitMethod).neverMatches());
+       }
+
+       public void testCallAndThisMatchesMethodCall() {
+               StandardPointcutExpression ex = pointcutParser.parsePointcutExpression("call(* *(..)) && this(java.util.ArrayList)");
+               ResolvedType jlString = world.resolve("java.lang.String");
+               ResolvedType juList = world.resolve("java.util.List");
 
-               // was execution((* *..A.aa(..))
-               // assertTrue("Should match execution of A.aa", ex.matchesMethodExecution(aa).alwaysMatches());
-               // assertTrue("Should match execution of B.aa", ex.matchesMethodExecution(bsaa).alwaysMatches());
-               // assertTrue("Should not match execution of A.a", ex.matchesMethodExecution(a).neverMatches());
-               // ex = p.parsePointcutExpression("call(* *..A.a*(int))");
-               // assertTrue("Should not match execution of A.a", ex.matchesMethodExecution(a).neverMatches());
-               //
-               // // test this
-               // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               // assertTrue("Should match A", ex.matchesMethodExecution(a).alwaysMatches());
-               // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               // assertTrue("Maybe matches B", ex.matchesMethodExecution(a).maybeMatches());
-               // assertFalse("Maybe matches B", ex.matchesMethodExecution(a).alwaysMatches());
-               //
-               // // test target
-               // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               // assertTrue("Should match A", ex.matchesMethodExecution(a).alwaysMatches());
-               // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               // assertTrue("Maybe matches B", ex.matchesMethodExecution(a).maybeMatches());
-               // assertFalse("Maybe matches B", ex.matchesMethodExecution(a).alwaysMatches());
-               //
-               // // test args
-               // ex = p.parsePointcutExpression("args(..,int)");
-               // assertTrue("Should match A.aa", ex.matchesMethodExecution(aa).alwaysMatches());
-               // assertTrue("Should match A.aaa", ex.matchesMethodExecution(aaa).alwaysMatches());
-               // assertTrue("Should not match A.a", ex.matchesMethodExecution(a).neverMatches());
-               //
-               // // within
-               // ex = p.parsePointcutExpression("within(*..A)");
-               // assertTrue("Matches in class A", ex.matchesMethodExecution(a).alwaysMatches());
-               // assertTrue("Does not match in class B", ex.matchesMethodExecution(bsaa).neverMatches());
-               //
-               // // withincode
-               // ex = p.parsePointcutExpression("withincode(* a*(..))");
-               // assertTrue("Should not match", ex.matchesMethodExecution(a).neverMatches());
+               ResolvedMember stringSplitMethod = getMethod(jlString, "split", "(Ljava/lang/String;I)[Ljava/lang/String;");
+               ResolvedMember stringValueOfIntMethod = getMethod(jlString, "valueOf", "(I)Ljava/lang/String;");
+               ResolvedMember listAddMethod = getMethod(juList, "add", "(Ljava/lang/Object;)Z");
+
+               // Calling from list.add() to string split, the callee *might* be an ArrayList, so possible match
+               assertTrue(ex.matchesMethodCall(stringSplitMethod, listAddMethod).maybeMatches());
        }
 
-       // public void testMatchesMethodCall() {
        // PointcutExpression ex = p.parsePointcutExpression("call(* *..A.a*(..))");
        // assertTrue("Should match call to A.a()", ex.matchesMethodCall(a, a).alwaysMatches());
        // assertTrue("Should match call to A.aaa()", ex.matchesMethodCall(aaa, a).alwaysMatches());
@@ -319,6 +402,18 @@ public abstract class CommonPointcutExpressionTests extends TestCase {
        // assertTrue("Matches within aa", ex.matchesHandler(Exception.class, aa).alwaysMatches());
        // assertTrue("Does not match within b", ex.matchesHandler(Exception.class, b).neverMatches());
        // }
+       // -- next few tests relate to matching different pointcut expressions against a staticinitialization join point
+
+       public void testMethodMatchesStaticInitialization() {
+               StandardPointcutExpression ex = pointcutParser.parsePointcutExpression("staticinitialization(java.lang.String)");
+               assertNotNull(ex);
+
+               ResolvedType jlString = world.resolve("java.lang.String");
+
+               boolean b = ex.matchesStaticInitialization(jlString).alwaysMatches();
+               assertTrue(b);
+       }
+
        //
        // public void testMatchesInitialization() {
        // PointcutExpression ex = p.parsePointcutExpression("initialization(new(String))");
@@ -575,56 +670,7 @@ public abstract class CommonPointcutExpressionTests extends TestCase {
        // assertTrue("Dynamic test needed", ex.mayNeedDynamicTest());
        // }
 
-       // static class A {
-       // public A(String s) {
-       // }
-       //
-       // public void a() {
-       // }
-       //
-       // public void aa(int i) {
-       // }
-       //
-       // public void aaa(String s, int i) {
-       // }
-       //
-       // int x;
-       // }
-       //
-       // static class B extends A {
-       // public B() {
-       // super("");
-       // }
-       //
-       // public B(String s) {
-       // super(s);
-       // }
-       //
-       // public String b() {
-       // return null;
-       // }
-       //
-       // public void aa(int i) {
-       // }
-       //
-       // int y;
-       // }
-       //
-       // static class Client {
-       // public Client() {
-       // }
-       //
-       // Number n;
-       //
-       // public void foo(String s, int i, Number n) {
-       // }
-       //
-       // public void bar(String s, int i, Integer i2, Number n) {
-       // }
-       // }
-       //
-       // static class X {
-       // }
+       // -- helpers
 
        private ResolvedMember getMethod(ResolvedType type, String methodName, String methodSignature) {
                ResolvedMember[] methods = type.getDeclaredMethods();
diff --git a/org.aspectj.matcher/testsrc/org/aspectj/matcher/tools/FurtherCommonPointcutExpressionTests.java b/org.aspectj.matcher/testsrc/org/aspectj/matcher/tools/FurtherCommonPointcutExpressionTests.java
new file mode 100644 (file)
index 0000000..03860c0
--- /dev/null
@@ -0,0 +1,658 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Contributors
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Andy Clement
+ *******************************************************************************/
+package org.aspectj.matcher.tools;
+
+import junit.framework.TestCase;
+
+import org.aspectj.weaver.ResolvedMember;
+import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.tools.StandardPointcutExpression;
+import org.aspectj.weaver.tools.StandardPointcutParser;
+
+/**
+ * Test the use of the pointcut parser and matching infrastructure. The org.aspectj.matcher.tools infrastructure used should not be
+ * aware of what kind of World it is working with and only operate in terms of the type abstraction expressed in the
+ * org.aspectj.matcher project (so Members, etc). These tests require some testdata types.
+ * 
+ * This is based on the Reflection oriented PointcutExpressionTest in the weaver project.
+ * 
+ * @author Andy Clement
+ */
+public abstract class FurtherCommonPointcutExpressionTests extends TestCase {
+
+       private World world;
+       private StandardPointcutParser pointcutParser;
+
+       protected abstract World getWorld();
+
+       protected void setUp() throws Exception {
+               super.setUp();
+               world = getWorld();
+               pointcutParser = StandardPointcutParser.getPointcutParserSupportingAllPrimitives(world);
+       }
+
+       // public void testResolvingOneType() {
+       // // do it via name
+       // ResolvedType type = world.resolve("java.lang.String");
+       // assertNotNull(type);
+       // // do it via signature
+       // type = world.resolve(UnresolvedType.forSignature("Ljava/lang/String;"));
+       // assertNotNull(type);
+       // }
+       //
+       // public void testResolveTypeAndRetrieveMethod() {
+       // ResolvedType type = world.resolve("java.lang.String");
+       // assertNotNull(type);
+       // ResolvedMember method = getMethod(type, "valueOf", "(Z)Ljava/lang/String;"); // grab the method 'String valueOf()'
+       // assertNotNull(method);
+       // }
+       //
+       // public void testMethodExecutionMatching01() {
+       // checkAlwaysMatches("execution(String valueOf(boolean))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
+       // }
+       //
+       // public void testMethodExecutionMatching02() {
+       // checkAlwaysMatches("execution(* *val*(..))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
+       // checkAlwaysMatches("execution(String *(..))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
+       // checkAlwaysMatches("execution(* *(boolean))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
+       // checkAlwaysMatches("execution(* j*..*.valueOf(..))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
+       // checkAlwaysMatches("execution(* *(*))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
+       //
+       // checkNeverMatches("execution(* vulueOf(..))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
+       // checkNeverMatches("execution(int *(..))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
+       // checkNeverMatches("execution(* valueOf(String))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
+       // checkNeverMatches("execution(private * valueOf(..))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
+       // }
+       //
+       // public void testMethodExecutionMatching03() {
+       // checkAlwaysMatches("execution(* *())", "java.util.List", "toArray", "()[Ljava/lang/Object;");
+       // checkAlwaysMatches("execution(*[] *())", "java.util.List", "toArray", "()[Ljava/lang/Object;");
+       // checkAlwaysMatches("execution(*b*[] *())", "java.util.List", "toArray", "()[Ljava/lang/Object;");
+       // }
+       //
+       // public void testMethodMatchesStaticInitialization() {
+       // StandardPointcutExpression ex = pointcutParser.parsePointcutExpression("staticinitialization(java.lang.String)");
+       // assertNotNull(ex);
+       //
+       // ResolvedType jlString = world.resolve("java.lang.String");
+       //
+       // boolean b = ex.matchesStaticInitialization(jlString).alwaysMatches();
+       // assertTrue(b);
+       // }
+
+       // public void testMethodExecutionMatching04() {
+       // was execution((* *..A.aa(..))
+       // assertTrue("Should match execution of A.aa", ex.matchesMethodExecution(aa).alwaysMatches());
+       // assertTrue("Should match execution of B.aa", ex.matchesMethodExecution(bsaa).alwaysMatches());
+       // assertTrue("Should not match execution of A.a", ex.matchesMethodExecution(a).neverMatches());
+       // ex = p.parsePointcutExpression("call(* *..A.a*(int))");
+       // assertTrue("Should not match execution of A.a", ex.matchesMethodExecution(a).neverMatches());
+       //
+       // // test this
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // assertTrue("Should match A", ex.matchesMethodExecution(a).alwaysMatches());
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Maybe matches B", ex.matchesMethodExecution(a).maybeMatches());
+       // assertFalse("Maybe matches B", ex.matchesMethodExecution(a).alwaysMatches());
+       //
+       // // test target
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // assertTrue("Should match A", ex.matchesMethodExecution(a).alwaysMatches());
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Maybe matches B", ex.matchesMethodExecution(a).maybeMatches());
+       // assertFalse("Maybe matches B", ex.matchesMethodExecution(a).alwaysMatches());
+       //
+       // // test args
+       // ex = p.parsePointcutExpression("args(..,int)");
+       // assertTrue("Should match A.aa", ex.matchesMethodExecution(aa).alwaysMatches());
+       // assertTrue("Should match A.aaa", ex.matchesMethodExecution(aaa).alwaysMatches());
+       // assertTrue("Should not match A.a", ex.matchesMethodExecution(a).neverMatches());
+       //
+       // // within
+       // ex = p.parsePointcutExpression("within(*..A)");
+       // assertTrue("Matches in class A", ex.matchesMethodExecution(a).alwaysMatches());
+       // assertTrue("Does not match in class B", ex.matchesMethodExecution(bsaa).neverMatches());
+       //
+       // // withincode
+       // ex = p.parsePointcutExpression("withincode(* a*(..))");
+       // assertTrue("Should not match", ex.matchesMethodExecution(a).neverMatches());
+
+       // public void testMatchesMethodCall() {
+       // PointcutExpression ex = p.parsePointcutExpression("call(* *..A.a*(..))");
+       // assertTrue("Should match call to A.a()", ex.matchesMethodCall(a, a).alwaysMatches());
+       // assertTrue("Should match call to A.aaa()", ex.matchesMethodCall(aaa, a).alwaysMatches());
+       // assertTrue("Should match call to B.aa()", ex.matchesMethodCall(bsaa, a).alwaysMatches());
+       // assertTrue("Should not match call to B.b()", ex.matchesMethodCall(b, a).neverMatches());
+       // ex = p.parsePointcutExpression("call(* *..A.a*(int))");
+       // assertTrue("Should match call to A.aa()", ex.matchesMethodCall(aa, a).alwaysMatches());
+       // assertTrue("Should not match call to A.a()", ex.matchesMethodCall(a, a).neverMatches());
+       // ex = p.parsePointcutExpression("call(void aaa(..)) && this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
+       // assertTrue("Should match call to A.aaa() from Client", ex.matchesMethodCall(aaa, foo).alwaysMatches());
+       // ex = p.parsePointcutExpression("call(void aaa(..)) && this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Should match call to A.aaa() from B", ex.matchesMethodCall(aaa, b).alwaysMatches());
+       // assertTrue("May match call to A.aaa() from A", ex.matchesMethodCall(aaa, a).maybeMatches());
+       // assertFalse("May match call to A.aaa() from A", ex.matchesMethodCall(aaa, a).alwaysMatches());
+       // ex = p.parsePointcutExpression("execution(* *.*(..))");
+       // assertTrue("Should not match call to A.aa", ex.matchesMethodCall(aa, a).neverMatches());
+       // // this
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
+       // assertTrue("Should match Client", ex.matchesMethodCall(a, foo).alwaysMatches());
+       // assertTrue("Should not match A", ex.matchesMethodCall(a, a).neverMatches());
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Should maybe match B", ex.matchesMethodCall(bsaa, a).maybeMatches());
+       // assertFalse("Should maybe match B", ex.matchesMethodCall(bsaa, a).alwaysMatches());
+       // // target
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
+       // assertTrue("Should not match Client", ex.matchesMethodCall(a, a).neverMatches());
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // assertTrue("Should match A", ex.matchesMethodCall(a, a).alwaysMatches());
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Should maybe match A", ex.matchesMethodCall(aa, a).maybeMatches());
+       // assertFalse("Should maybe match A", ex.matchesMethodCall(aa, a).alwaysMatches());
+       // // test args
+       // ex = p.parsePointcutExpression("args(..,int)");
+       // assertTrue("Should match A.aa", ex.matchesMethodCall(aa, a).alwaysMatches());
+       // assertTrue("Should match A.aaa", ex.matchesMethodCall(aaa, a).alwaysMatches());
+       // assertTrue("Should not match A.a", ex.matchesMethodCall(a, a).neverMatches());
+       // // within
+       // ex = p.parsePointcutExpression("within(*..A)");
+       // assertTrue("Matches in class A", ex.matchesMethodCall(a, a).alwaysMatches());
+       // assertTrue("Does not match in class B", ex.matchesMethodCall(a, b).neverMatches());
+       // assertTrue("Matches in class A", ex.matchesMethodCall(a, A.class).alwaysMatches());
+       // assertTrue("Does not match in class B", ex.matchesMethodCall(a, B.class).neverMatches());
+       // // withincode
+       // ex = p.parsePointcutExpression("withincode(* a*(..))");
+       // assertTrue("Should match", ex.matchesMethodCall(b, bsaa).alwaysMatches());
+       // assertTrue("Should not match", ex.matchesMethodCall(b, b).neverMatches());
+       // }
+       // public void testMatchesConstructorCall() {
+       // PointcutExpression ex = p.parsePointcutExpression("call(new(String))");
+       // assertTrue("Should match A(String)", ex.matchesConstructorCall(asCons, b).alwaysMatches());
+       // assertTrue("Should match B(String)", ex.matchesConstructorCall(bsStringCons, b).alwaysMatches());
+       // assertTrue("Should not match B()", ex.matchesConstructorCall(bsCons, foo).neverMatches());
+       // ex = p.parsePointcutExpression("call(*..A.new(String))");
+       // assertTrue("Should match A(String)", ex.matchesConstructorCall(asCons, b).alwaysMatches());
+       // assertTrue("Should not match B(String)", ex.matchesConstructorCall(bsStringCons, foo).neverMatches());
+       // // this
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
+       // assertTrue("Should match Client", ex.matchesConstructorCall(asCons, foo).alwaysMatches());
+       // assertTrue("Should not match A", ex.matchesConstructorCall(asCons, a).neverMatches());
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Should maybe match B", ex.matchesConstructorCall(asCons, a).maybeMatches());
+       // assertFalse("Should maybe match B", ex.matchesConstructorCall(asCons, a).alwaysMatches());
+       // // target
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
+       // assertTrue("Should not match Client", ex.matchesConstructorCall(asCons, foo).neverMatches());
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // assertTrue("Should not match A (no target)", ex.matchesConstructorCall(asCons, a).neverMatches());
+       // // args
+       // ex = p.parsePointcutExpression("args(String)");
+       // assertTrue("Should match A(String)", ex.matchesConstructorCall(asCons, b).alwaysMatches());
+       // assertTrue("Should match B(String)", ex.matchesConstructorCall(bsStringCons, foo).alwaysMatches());
+       // assertTrue("Should not match B()", ex.matchesConstructorCall(bsCons, foo).neverMatches());
+       // // within
+       // ex = p.parsePointcutExpression("within(*..A)");
+       // assertTrue("Matches in class A", ex.matchesConstructorCall(asCons, a).alwaysMatches());
+       // assertTrue("Does not match in class B", ex.matchesConstructorCall(asCons, b).neverMatches());
+       // // withincode
+       // ex = p.parsePointcutExpression("withincode(* a*(..))");
+       // assertTrue("Should match", ex.matchesConstructorCall(bsCons, aa).alwaysMatches());
+       // assertTrue("Should not match", ex.matchesConstructorCall(bsCons, b).neverMatches());
+       // }
+       //
+       // public void testMatchesConstructorExecution() {
+       // PointcutExpression ex = p.parsePointcutExpression("execution(new(String))");
+       // assertTrue("Should match A(String)", ex.matchesConstructorExecution(asCons).alwaysMatches());
+       // assertTrue("Should match B(String)", ex.matchesConstructorExecution(bsStringCons).alwaysMatches());
+       // assertTrue("Should not match B()", ex.matchesConstructorExecution(bsCons).neverMatches());
+       // ex = p.parsePointcutExpression("execution(*..A.new(String))");
+       // assertTrue("Should match A(String)", ex.matchesConstructorExecution(asCons).alwaysMatches());
+       // assertTrue("Should not match B(String)", ex.matchesConstructorExecution(bsStringCons).neverMatches());
+       //
+       // // test this
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // assertTrue("Should match A", ex.matchesConstructorExecution(asCons).alwaysMatches());
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Maybe matches B", ex.matchesConstructorExecution(asCons).maybeMatches());
+       // assertFalse("Maybe matches B", ex.matchesConstructorExecution(asCons).alwaysMatches());
+       // assertTrue("Should match B", ex.matchesConstructorExecution(bsCons).alwaysMatches());
+       // assertTrue("Does not match client", ex.matchesConstructorExecution(clientCons).neverMatches());
+       //
+       // // test target
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // assertTrue("Should match A", ex.matchesConstructorExecution(asCons).alwaysMatches());
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Maybe matches B", ex.matchesConstructorExecution(asCons).maybeMatches());
+       // assertFalse("Maybe matches B", ex.matchesConstructorExecution(asCons).alwaysMatches());
+       // assertTrue("Should match B", ex.matchesConstructorExecution(bsCons).alwaysMatches());
+       // assertTrue("Does not match client", ex.matchesConstructorExecution(clientCons).neverMatches());
+       //
+       // // within
+       // ex = p.parsePointcutExpression("within(*..A)");
+       // assertTrue("Matches in class A", ex.matchesConstructorExecution(asCons).alwaysMatches());
+       // assertTrue("Does not match in class B", ex.matchesConstructorExecution(bsCons).neverMatches());
+       //
+       // // withincode
+       // ex = p.parsePointcutExpression("withincode(* a*(..))");
+       // assertTrue("Does not match", ex.matchesConstructorExecution(bsCons).neverMatches());
+       //
+       // // args
+       // ex = p.parsePointcutExpression("args(String)");
+       // assertTrue("Should match A(String)", ex.matchesConstructorExecution(asCons).alwaysMatches());
+       // assertTrue("Should match B(String)", ex.matchesConstructorExecution(bsStringCons).alwaysMatches());
+       // assertTrue("Should not match B()", ex.matchesConstructorExecution(bsCons).neverMatches());
+       // }
+       //
+       // public void testMatchesAdviceExecution() {
+       // PointcutExpression ex = p.parsePointcutExpression("adviceexecution()");
+       // assertTrue("Should match (advice) A.a", ex.matchesAdviceExecution(a).alwaysMatches());
+       // // test this
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
+       // assertTrue("Should match Client", ex.matchesAdviceExecution(foo).alwaysMatches());
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Maybe matches B", ex.matchesAdviceExecution(a).maybeMatches());
+       // assertFalse("Maybe matches B", ex.matchesAdviceExecution(a).alwaysMatches());
+       // assertTrue("Does not match client", ex.matchesAdviceExecution(foo).neverMatches());
+       //
+       // // test target
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
+       // assertTrue("Should match Client", ex.matchesAdviceExecution(foo).alwaysMatches());
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Maybe matches B", ex.matchesAdviceExecution(a).maybeMatches());
+       // assertFalse("Maybe matches B", ex.matchesAdviceExecution(a).alwaysMatches());
+       // assertTrue("Does not match client", ex.matchesAdviceExecution(foo).neverMatches());
+       //
+       // // test within
+       // ex = p.parsePointcutExpression("within(*..A)");
+       // assertTrue("Matches in class A", ex.matchesAdviceExecution(a).alwaysMatches());
+       // assertTrue("Does not match in class B", ex.matchesAdviceExecution(b).neverMatches());
+       //
+       // // withincode
+       // ex = p.parsePointcutExpression("withincode(* a*(..))");
+       // assertTrue("Does not match", ex.matchesAdviceExecution(a).neverMatches());
+       //
+       // // test args
+       // ex = p.parsePointcutExpression("args(..,int)");
+       // assertTrue("Should match A.aa", ex.matchesAdviceExecution(aa).alwaysMatches());
+       // assertTrue("Should match A.aaa", ex.matchesAdviceExecution(aaa).alwaysMatches());
+       // assertTrue("Should not match A.a", ex.matchesAdviceExecution(a).neverMatches());
+       // }
+       //
+       // public void testMatchesHandler() {
+       // PointcutExpression ex = p.parsePointcutExpression("handler(Exception)");
+       // assertTrue("Should match catch(Exception)", ex.matchesHandler(Exception.class, Client.class).alwaysMatches());
+       // assertTrue("Should not match catch(Throwable)", ex.matchesHandler(Throwable.class, Client.class).neverMatches());
+       // // test this
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
+       // assertTrue("Should match Client", ex.matchesHandler(Exception.class, foo).alwaysMatches());
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Maybe matches B", ex.matchesHandler(Exception.class, a).maybeMatches());
+       // assertFalse("Maybe matches B", ex.matchesHandler(Exception.class, a).alwaysMatches());
+       // assertTrue("Does not match client", ex.matchesHandler(Exception.class, foo).neverMatches());
+       // // target - no target for exception handlers
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
+       // assertTrue("Should match Client", ex.matchesHandler(Exception.class, foo).neverMatches());
+       // // args
+       // ex = p.parsePointcutExpression("args(Exception)");
+       // assertTrue("Should match Exception", ex.matchesHandler(Exception.class, foo).alwaysMatches());
+       // assertTrue("Should match RuntimeException", ex.matchesHandler(RuntimeException.class, foo).alwaysMatches());
+       // assertTrue("Should not match String", ex.matchesHandler(String.class, foo).neverMatches());
+       // assertTrue("Maybe matches Throwable", ex.matchesHandler(Throwable.class, foo).maybeMatches());
+       // assertFalse("Maybe matches Throwable", ex.matchesHandler(Throwable.class, foo).alwaysMatches());
+       // // within
+       // ex = p.parsePointcutExpression("within(*..Client)");
+       // assertTrue("Matches in class Client", ex.matchesHandler(Exception.class, foo).alwaysMatches());
+       // assertTrue("Does not match in class B", ex.matchesHandler(Exception.class, b).neverMatches());
+       // // withincode
+       // ex = p.parsePointcutExpression("withincode(* a*(..))");
+       // assertTrue("Matches within aa", ex.matchesHandler(Exception.class, aa).alwaysMatches());
+       // assertTrue("Does not match within b", ex.matchesHandler(Exception.class, b).neverMatches());
+       // }
+       //
+       // public void testMatchesInitialization() {
+       // PointcutExpression ex = p.parsePointcutExpression("initialization(new(String))");
+       // assertTrue("Should match A(String)", ex.matchesInitialization(asCons).alwaysMatches());
+       // assertTrue("Should match B(String)", ex.matchesInitialization(bsStringCons).alwaysMatches());
+       // assertTrue("Should not match B()", ex.matchesInitialization(bsCons).neverMatches());
+       // ex = p.parsePointcutExpression("initialization(*..A.new(String))");
+       // assertTrue("Should match A(String)", ex.matchesInitialization(asCons).alwaysMatches());
+       // assertTrue("Should not match B(String)", ex.matchesInitialization(bsStringCons).neverMatches());
+       // // test this
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // assertTrue("Should match A", ex.matchesInitialization(asCons).alwaysMatches());
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Maybe matches B", ex.matchesInitialization(asCons).maybeMatches());
+       // assertFalse("Maybe matches B", ex.matchesInitialization(asCons).alwaysMatches());
+       //
+       // // test target
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // assertTrue("Should match A", ex.matchesInitialization(asCons).alwaysMatches());
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("Maybe matches B", ex.matchesInitialization(asCons).maybeMatches());
+       // assertFalse("Maybe matches B", ex.matchesInitialization(asCons).alwaysMatches());
+       // // within
+       // ex = p.parsePointcutExpression("within(*..A)");
+       // assertTrue("Matches in class A", ex.matchesInitialization(asCons).alwaysMatches());
+       // assertTrue("Does not match in class B", ex.matchesInitialization(bsCons).neverMatches());
+       // // withincode
+       // ex = p.parsePointcutExpression("withincode(* a*(..))");
+       // assertTrue("Does not match", ex.matchesInitialization(bsCons).neverMatches());
+       // // args
+       // ex = p.parsePointcutExpression("args(String)");
+       // assertTrue("Should match A(String)", ex.matchesInitialization(asCons).alwaysMatches());
+       // assertTrue("Should match B(String)", ex.matchesInitialization(bsStringCons).alwaysMatches());
+       // assertTrue("Should not match B()", ex.matchesInitialization(bsCons).neverMatches());
+       // }
+       //
+       // public void testMatchesPreInitialization() {
+       // PointcutExpression ex = p.parsePointcutExpression("preinitialization(new(String))");
+       // assertTrue("Should match A(String)", ex.matchesPreInitialization(asCons).alwaysMatches());
+       // assertTrue("Should match B(String)", ex.matchesPreInitialization(bsStringCons).alwaysMatches());
+       // assertTrue("Should not match B()", ex.matchesPreInitialization(bsCons).neverMatches());
+       // ex = p.parsePointcutExpression("preinitialization(*..A.new(String))");
+       // assertTrue("Should match A(String)", ex.matchesPreInitialization(asCons).alwaysMatches());
+       // assertTrue("Should not match B(String)", ex.matchesPreInitialization(bsStringCons).neverMatches());
+       // // test this
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // assertTrue("No match, no this at preinit", ex.matchesPreInitialization(asCons).neverMatches());
+       //
+       // // test target
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // assertTrue("No match, no target at preinit", ex.matchesPreInitialization(asCons).neverMatches());
+       //
+       // // within
+       // ex = p.parsePointcutExpression("within(*..A)");
+       // assertTrue("Matches in class A", ex.matchesPreInitialization(asCons).alwaysMatches());
+       // assertTrue("Does not match in class B", ex.matchesPreInitialization(bsCons).neverMatches());
+       // // withincode
+       // ex = p.parsePointcutExpression("withincode(* a*(..))");
+       // assertTrue("Does not match", ex.matchesPreInitialization(bsCons).neverMatches());
+       // // args
+       // ex = p.parsePointcutExpression("args(String)");
+       // assertTrue("Should match A(String)", ex.matchesPreInitialization(asCons).alwaysMatches());
+       // assertTrue("Should match B(String)", ex.matchesPreInitialization(bsStringCons).alwaysMatches());
+       // assertTrue("Should not match B()", ex.matchesPreInitialization(bsCons).neverMatches());
+       // }
+       //
+       // public void testMatchesStaticInitialization() {
+       // // staticinit
+       // PointcutExpression ex = p.parsePointcutExpression("staticinitialization(*..A+)");
+       // assertTrue("Matches A", ex.matchesStaticInitialization(A.class).alwaysMatches());
+       // assertTrue("Matches B", ex.matchesStaticInitialization(B.class).alwaysMatches());
+       // assertTrue("Doesn't match Client", ex.matchesStaticInitialization(Client.class).neverMatches());
+       // // this
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // assertTrue("No this", ex.matchesStaticInitialization(A.class).neverMatches());
+       // // target
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // assertTrue("No target", ex.matchesStaticInitialization(A.class).neverMatches());
+       //
+       // // args
+       // ex = p.parsePointcutExpression("args()");
+       // assertTrue("No args", ex.matchesStaticInitialization(A.class).alwaysMatches());
+       // ex = p.parsePointcutExpression("args(String)");
+       // assertTrue("No args", ex.matchesStaticInitialization(A.class).neverMatches());
+       //
+       // // within
+       // ex = p.parsePointcutExpression("within(*..A)");
+       // assertTrue("Matches in class A", ex.matchesStaticInitialization(A.class).alwaysMatches());
+       // assertTrue("Does not match in class B", ex.matchesStaticInitialization(B.class).neverMatches());
+       //
+       // // withincode
+       // ex = p.parsePointcutExpression("withincode(* a*(..))");
+       // assertTrue("Does not match", ex.matchesStaticInitialization(A.class).neverMatches());
+       // }
+       //
+       // public void testMatchesFieldSet() {
+       // PointcutExpression ex = p.parsePointcutExpression("set(* *..A+.*)");
+       // assertTrue("matches x", ex.matchesFieldSet(x, a).alwaysMatches());
+       // assertTrue("matches y", ex.matchesFieldSet(y, foo).alwaysMatches());
+       // assertTrue("does not match n", ex.matchesFieldSet(n, foo).neverMatches());
+       // // this
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
+       // assertTrue("matches Client", ex.matchesFieldSet(x, foo).alwaysMatches());
+       // assertTrue("does not match A", ex.matchesFieldSet(n, a).neverMatches());
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("maybe matches A", ex.matchesFieldSet(x, a).maybeMatches());
+       // assertFalse("maybe matches A", ex.matchesFieldSet(x, a).alwaysMatches());
+       // // target
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("matches B", ex.matchesFieldSet(y, foo).alwaysMatches());
+       // assertTrue("maybe matches A", ex.matchesFieldSet(x, foo).maybeMatches());
+       // assertFalse("maybe matches A", ex.matchesFieldSet(x, foo).alwaysMatches());
+       // // args
+       // ex = p.parsePointcutExpression("args(int)");
+       // assertTrue("matches x", ex.matchesFieldSet(x, a).alwaysMatches());
+       // assertTrue("matches y", ex.matchesFieldSet(y, a).alwaysMatches());
+       // assertTrue("does not match n", ex.matchesFieldSet(n, a).neverMatches());
+       // // within
+       // ex = p.parsePointcutExpression("within(*..A)");
+       // assertTrue("Matches in class A", ex.matchesFieldSet(x, a).alwaysMatches());
+       // assertTrue("Does not match in class B", ex.matchesFieldSet(x, b).neverMatches());
+       // // withincode
+       // ex = p.parsePointcutExpression("withincode(* a*(..))");
+       // assertTrue("Should match", ex.matchesFieldSet(x, aa).alwaysMatches());
+       // assertTrue("Should not match", ex.matchesFieldSet(x, b).neverMatches());
+       // }
+       //
+       // public void testMatchesFieldGet() {
+       // PointcutExpression ex = p.parsePointcutExpression("get(* *..A+.*)");
+       // assertTrue("matches x", ex.matchesFieldGet(x, a).alwaysMatches());
+       // assertTrue("matches y", ex.matchesFieldGet(y, foo).alwaysMatches());
+       // assertTrue("does not match n", ex.matchesFieldGet(n, foo).neverMatches());
+       // // this
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
+       // assertTrue("matches Client", ex.matchesFieldGet(x, foo).alwaysMatches());
+       // assertTrue("does not match A", ex.matchesFieldGet(n, a).neverMatches());
+       // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("maybe matches A", ex.matchesFieldGet(x, a).maybeMatches());
+       // assertFalse("maybe matches A", ex.matchesFieldGet(x, a).alwaysMatches());
+       // // target
+       // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertTrue("matches B", ex.matchesFieldGet(y, foo).alwaysMatches());
+       // assertTrue("maybe matches A", ex.matchesFieldGet(x, foo).maybeMatches());
+       // assertFalse("maybe matches A", ex.matchesFieldGet(x, foo).alwaysMatches());
+       // // args - no args at get join point
+       // ex = p.parsePointcutExpression("args(int)");
+       // assertTrue("matches x", ex.matchesFieldGet(x, a).neverMatches());
+       // // within
+       // ex = p.parsePointcutExpression("within(*..A)");
+       // assertTrue("Matches in class A", ex.matchesFieldGet(x, a).alwaysMatches());
+       // assertTrue("Does not match in class B", ex.matchesFieldGet(x, b).neverMatches());
+       // // withincode
+       // ex = p.parsePointcutExpression("withincode(* a*(..))");
+       // assertTrue("Should match", ex.matchesFieldGet(x, aa).alwaysMatches());
+       // assertTrue("Should not match", ex.matchesFieldGet(x, b).neverMatches());
+       // }
+       //
+       // public void testArgsMatching() {
+       // // too few args
+       // PointcutExpression ex = p.parsePointcutExpression("args(*,*,*,*)");
+       // assertTrue("Too few args", ex.matchesMethodExecution(foo).neverMatches());
+       // assertTrue("Matching #args", ex.matchesMethodExecution(bar).alwaysMatches());
+       // // one too few + ellipsis
+       // ex = p.parsePointcutExpression("args(*,*,*,..)");
+       // assertTrue("Matches with ellipsis", ex.matchesMethodExecution(foo).alwaysMatches());
+       // // exact number + ellipsis
+       // assertTrue("Matches with ellipsis", ex.matchesMethodExecution(bar).alwaysMatches());
+       // assertTrue("Does not match with ellipsis", ex.matchesMethodExecution(a).neverMatches());
+       // // too many + ellipsis
+       // ex = p.parsePointcutExpression("args(*,..,*)");
+       // assertTrue("Matches with ellipsis", ex.matchesMethodExecution(bar).alwaysMatches());
+       // assertTrue("Does not match with ellipsis", ex.matchesMethodExecution(a).neverMatches());
+       // assertTrue("Matches with ellipsis", ex.matchesMethodExecution(aaa).alwaysMatches());
+       // // exact match
+       // ex = p.parsePointcutExpression("args(String,int,Number)");
+       // assertTrue("Matches exactly", ex.matchesMethodExecution(foo).alwaysMatches());
+       // // maybe match
+       // ex = p.parsePointcutExpression("args(String,int,Double)");
+       // assertTrue("Matches maybe", ex.matchesMethodExecution(foo).maybeMatches());
+       // assertFalse("Matches maybe", ex.matchesMethodExecution(foo).alwaysMatches());
+       // // never match
+       // ex = p.parsePointcutExpression("args(String,Integer,Number)");
+       // if (LangUtil.is15VMOrGreater()) {
+       // assertTrue("matches", ex.matchesMethodExecution(foo).alwaysMatches());
+       // } else {
+       // assertTrue("Does not match", ex.matchesMethodExecution(foo).neverMatches());
+       // }
+       // }
+       //
+       // // public void testMatchesDynamically() {
+       // // // everything other than this,target,args should just return true
+       // // PointcutExpression ex = p.parsePointcutExpression("call(* *.*(..)) && execution(* *.*(..)) &&" +
+       // // "get(* *) && set(* *) && initialization(new(..)) && preinitialization(new(..)) &&" +
+       // // "staticinitialization(X) && adviceexecution() && within(Y) && withincode(* *.*(..)))");
+       // // assertTrue("Matches dynamically",ex.matchesDynamically(a,b,new Object[0]));
+       // // // this
+       // // ex = p.parsePointcutExpression("this(String)");
+       // // assertTrue("String matches",ex.matchesDynamically("",this,new Object[0]));
+       // // assertFalse("Object doesn't match",ex.matchesDynamically(new Object(),this,new Object[0]));
+       // // ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // // assertTrue("A matches",ex.matchesDynamically(new A(""),this,new Object[0]));
+       // // assertTrue("B matches",ex.matchesDynamically(new B(""),this,new Object[0]));
+       // // // target
+       // // ex = p.parsePointcutExpression("target(String)");
+       // // assertTrue("String matches",ex.matchesDynamically(this,"",new Object[0]));
+       // // assertFalse("Object doesn't match",ex.matchesDynamically(this,new Object(),new Object[0]));
+       // // ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
+       // // assertTrue("A matches",ex.matchesDynamically(this,new A(""),new Object[0]));
+       // // assertTrue("B matches",ex.matchesDynamically(this,new B(""),new Object[0]));
+       // // // args
+       // // ex = p.parsePointcutExpression("args(*,*,*,*)");
+       // // assertFalse("Too few args",ex.matchesDynamically(null,null,new Object[]{a,b}));
+       // // assertTrue("Matching #args",ex.matchesDynamically(null,null,new Object[]{a,b,aa,aaa}));
+       // // // one too few + ellipsis
+       // // ex = p.parsePointcutExpression("args(*,*,*,..)");
+       // // assertTrue("Matches with ellipsis",ex.matchesDynamically(null,null,new Object[]{a,b,aa,aaa}));
+       // // // exact number + ellipsis
+       // // assertTrue("Matches with ellipsis",ex.matchesDynamically(null,null,new Object[]{a,b,aa}));
+       // // assertFalse("Does not match with ellipsis",ex.matchesDynamically(null,null,new Object[]{a,b}));
+       // // // too many + ellipsis
+       // // ex = p.parsePointcutExpression("args(*,..,*)");
+       // // assertTrue("Matches with ellipsis",ex.matchesDynamically(null,null,new Object[]{a,b,aa,aaa}));
+       // // assertFalse("Does not match with ellipsis",ex.matchesDynamically(null,null,new Object[]{a}));
+       // // assertTrue("Matches with ellipsis",ex.matchesDynamically(null,null,new Object[]{a,b}));
+       // // // exact match
+       // // ex = p.parsePointcutExpression("args(String,int,Number)");
+       // // assertTrue("Matches exactly",ex.matchesDynamically(null,null,new Object[]{"",new Integer(5),new Double(5.0)}));
+       // // ex = p.parsePointcutExpression("args(String,Integer,Number)");
+       // // assertTrue("Matches exactly",ex.matchesDynamically(null,null,new Object[]{"",new Integer(5),new Double(5.0)}));
+       // // // never match
+       // // ex = p.parsePointcutExpression("args(String,Integer,Number)");
+       // // assertFalse("Does not match",ex.matchesDynamically(null,null,new Object[]{a,b,aa}));
+       // // }
+       //
+       // public void testGetPointcutExpression() {
+       // PointcutExpression ex = p.parsePointcutExpression("staticinitialization(*..A+)");
+       // assertEquals("staticinitialization(*..A+)", ex.getPointcutExpression());
+       // }
+       //
+       // public void testCouldMatchJoinPointsInType() {
+       // PointcutExpression ex = p.parsePointcutExpression("execution(* org.aspectj.weaver.tools.PointcutExpressionTest.B.*(..))");
+       // assertTrue("Could maybe match String (as best we know at this point)", ex.couldMatchJoinPointsInType(String.class));
+       // assertTrue("Will always match B", ex.couldMatchJoinPointsInType(B.class));
+       // ex = p.parsePointcutExpression("within(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
+       // assertFalse("Will never match String", ex.couldMatchJoinPointsInType(String.class));
+       // assertTrue("Will always match B", ex.couldMatchJoinPointsInType(B.class));
+       // }
+       //
+       // public void testMayNeedDynamicTest() {
+       // PointcutExpression ex = p.parsePointcutExpression("execution(* org.aspectj.weaver.tools.PointcutExpressionTest.B.*(..))");
+       // assertFalse("No dynamic test needed", ex.mayNeedDynamicTest());
+       // ex = p
+       // .parsePointcutExpression("execution(* org.aspectj.weaver.tools.PointcutExpressionTest.B.*(..)) && args(org.aspectj.weaver.tools.PointcutExpressionTest.X)");
+       // assertTrue("Dynamic test needed", ex.mayNeedDynamicTest());
+       // }
+
+       // static class A {
+       // public A(String s) {
+       // }
+       //
+       // public void a() {
+       // }
+       //
+       // public void aa(int i) {
+       // }
+       //
+       // public void aaa(String s, int i) {
+       // }
+       //
+       // int x;
+       // }
+       //
+       // static class B extends A {
+       // public B() {
+       // super("");
+       // }
+       //
+       // public B(String s) {
+       // super(s);
+       // }
+       //
+       // public String b() {
+       // return null;
+       // }
+       //
+       // public void aa(int i) {
+       // }
+       //
+       // int y;
+       // }
+       //
+       // static class Client {
+       // public Client() {
+       // }
+       //
+       // Number n;
+       //
+       // public void foo(String s, int i, Number n) {
+       // }
+       //
+       // public void bar(String s, int i, Integer i2, Number n) {
+       // }
+       // }
+       //
+       // static class X {
+       // }
+
+       private ResolvedMember getMethod(ResolvedType type, String methodName, String methodSignature) {
+               ResolvedMember[] methods = type.getDeclaredMethods();
+               for (int i = 0; i < methods.length; i++) {
+                       if (methods[i].getName().equals(methodName)
+                                       && (methodSignature == null || methodSignature.equals(methods[i].getSignature()))) {
+                               return methods[i];
+                       }
+               }
+               return null;
+       }
+
+       private void checkAlwaysMatches(String pointcutExpression, String type, String methodName, String methodSignature) {
+               StandardPointcutExpression ex = pointcutParser.parsePointcutExpression(pointcutExpression);
+               assertNotNull(ex);
+               ResolvedType resolvedType = world.resolve(type);
+               ResolvedMember method = getMethod(resolvedType, methodName, methodSignature);
+               assertNotNull(method);
+               boolean b = ex.matchesMethodExecution(method).alwaysMatches();
+               assertTrue(b);
+       }
+
+       private void checkNeverMatches(String pointcutExpression, String type, String methodName, String methodSignature) {
+               StandardPointcutExpression ex = pointcutParser.parsePointcutExpression(pointcutExpression);
+               assertNotNull(ex);
+               ResolvedType resolvedType = world.resolve(type);
+               ResolvedMember method = getMethod(resolvedType, methodName, methodSignature);
+               assertNotNull(method);
+               boolean b = ex.matchesMethodExecution(method).neverMatches();
+               assertTrue(b);
+       }
+
+}