--- /dev/null
+
+aspect BadWormhole {
+
+ pointcut isDynamicService(Main mm,Service s):
+ cflowbelow(this(mm)) &&
+ if(true==true) &&
+ this(s);
+
+ //before(Main mm,Service s): isDynamicService(mm,s) {}
+ before(Service s): isDynamicService(*,s) {}
+}
--- /dev/null
+
+public interface GenericService {
+ public abstract void setContext(String localCtx);
+}
--- /dev/null
+
+public class Main {
+ public static void main(String []argv) {
+ new Service().setContext("foo");
+ }
+}
--- /dev/null
+
+public class Service implements GenericService {
+ String srvContext = "none";
+
+ public void setContext(String localCtx) {
+ this.srvContext=localCtx;
+ }
+}
}
- public ResolvedPointcutDefinition peekEnclosingDefinitition() {
- try {
- return (ResolvedPointcutDefinition)enclosingDefinition.get(enclosingDefinition.size()-1);
- } catch (IndexOutOfBoundsException e) {
- return null;
- }
+ public ResolvedPointcutDefinition peekEnclosingDefinition() {
+ if (enclosingDefinition.size()==0) return null;
+ return (ResolvedPointcutDefinition)enclosingDefinition.get(enclosingDefinition.size()-1);
}
if (!bindings.hasKey(freeVar)) continue;
int formalIndex = bindings.get(freeVar);
- ResolvedType formalType =
- bindings.getAdviceSignature().getParameterTypes()[formalIndex].resolve(world);
+
+ // We need to look in the right place for the type of the formal. Suppose the advice looks like this:
+ // before(String s): somePointcut(*,s)
+ // where the first argument in somePointcut is of type Number
+ // for free variable 0 we want to ask the pointcut for the type of its first argument, if we only
+ // ask the advice for the type of its first argument then we'll get the wrong type (pr86903)
+
+ ResolvedPointcutDefinition enclosingDef = bindings.peekEnclosingDefinition();
+ ResolvedType formalType = null;
+
+ // Is there a useful enclosing pointcut?
+ if (enclosingDef!=null && enclosingDef.getParameterTypes().length>0) {
+ formalType = enclosingDef.getParameterTypes()[freeVar].resolve(world);
+ } else {
+ formalType = bindings.getAdviceSignature().getParameterTypes()[formalIndex].resolve(world);
+ }
ConcreteCflowPointcut.Slot slot =
new ConcreteCflowPointcut.Slot(formalIndex, formalType, i);
final IfPointcut ret;
if (extraParameterFlags < 0 && testMethod == null) {
// @AJ style, we need to find the testMethod in the aspect defining the "if()" enclosing pointcut
- ResolvedPointcutDefinition def = bindings.peekEnclosingDefinitition();
+ ResolvedPointcutDefinition def = bindings.peekEnclosingDefinition();
if (def != null) {
ResolvedType aspect = inAspect.getWorld().resolve(def.getDeclaringType());
for (Iterator memberIter = aspect.getMethods(); memberIter.hasNext();) {
}
ret.residueSource = advice.getPointcut().concretize(inAspect, inAspect, ret.baseArgsCount, advice);
} else {
- ResolvedPointcutDefinition def = bindings.peekEnclosingDefinitition();
+ ResolvedPointcutDefinition def = bindings.peekEnclosingDefinition();
if (def == CflowPointcut.CFLOW_MARKER) {
inAspect.getWorld().showMessage(IMessage.ERROR,
WeaverMessages.format(WeaverMessages.IF_LEXICALLY_IN_CFLOW),