Browse Source

test and fix for 86903

tags/V1_5_0RC1
aclement 18 years ago
parent
commit
6e423f15e2

+ 11
- 0
tests/bugs150/pr86903/BadWormhole.java View File

@@ -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) {}
}

+ 4
- 0
tests/bugs150/pr86903/GenericService.java View File

@@ -0,0 +1,4 @@

public interface GenericService {
public abstract void setContext(String localCtx);
}

+ 6
- 0
tests/bugs150/pr86903/Main.java View File

@@ -0,0 +1,6 @@

public class Main {
public static void main(String []argv) {
new Service().setContext("foo");
}
}

+ 8
- 0
tests/bugs150/pr86903/Service.java View File

@@ -0,0 +1,8 @@

public class Service implements GenericService {
String srvContext = "none";

public void setContext(String localCtx) {
this.srvContext=localCtx;
}
}

+ 3
- 6
weaver/src/org/aspectj/weaver/IntMap.java View File

@@ -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);
}

+ 16
- 2
weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java View File

@@ -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);

+ 2
- 2
weaver/src/org/aspectj/weaver/patterns/IfPointcut.java View File

@@ -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),

Loading…
Cancel
Save