@@ -0,0 +1,11 @@ | |||
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) {} | |||
} |
@@ -0,0 +1,4 @@ | |||
public interface GenericService { | |||
public abstract void setContext(String localCtx); | |||
} |
@@ -0,0 +1,6 @@ | |||
public class Main { | |||
public static void main(String []argv) { | |||
new Service().setContext("foo"); | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
public class Service implements GenericService { | |||
String srvContext = "none"; | |||
public void setContext(String localCtx) { | |||
this.srvContext=localCtx; | |||
} | |||
} |
@@ -37,12 +37,9 @@ public class IntMap { | |||
} | |||
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); | |||
} | |||
@@ -243,8 +243,22 @@ public class CflowPointcut extends Pointcut { | |||
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); |
@@ -263,7 +263,7 @@ public class IfPointcut extends Pointcut { | |||
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();) { | |||
@@ -327,7 +327,7 @@ public class IfPointcut extends Pointcut { | |||
} | |||
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), |