diff options
author | aclement <aclement> | 2004-02-25 11:14:32 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-02-25 11:14:32 +0000 |
commit | fbc0aa305ea367e5fbeb99acf9907ae3a155f16a (patch) | |
tree | 1bc9275ebe1b24ca93f33ab92e1819b0aa2eb9d5 /weaver | |
parent | 5d3620130376b1356934f87483fa3686aeb51429 (diff) | |
download | aspectj-fbc0aa305ea367e5fbeb99acf9907ae3a155f16a.tar.gz aspectj-fbc0aa305ea367e5fbeb99acf9907ae3a155f16a.zip |
Fix for Bugzilla Bug 51320
ClasscastException on concretization of if(false)
(i.e. you can't use if/target/args/cflow/cflowbelow/this in deow - you get an error if you try)
Diffstat (limited to 'weaver')
4 files changed, 43 insertions, 1 deletions
diff --git a/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java index 382ace4ad..7c6410623 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java @@ -20,6 +20,7 @@ import java.io.IOException; import org.aspectj.bridge.IMessage; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.BetaException; +import org.aspectj.weaver.Checker; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; @@ -88,6 +89,13 @@ public class ArgsPointcut extends NameBindingPointcut { public Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) { + if (bindings.getEnclosingAdvice() instanceof Checker) { + // Enforce rule about which designators are supported in deow + inAspect.getWorld().showMessage(IMessage.ERROR, + "args() pointcut designator cannot be used in declare statement", + bindings.getEnclosingAdvice().getSourceLocation(), null); + return Pointcut.makeMatchesNothing(Pointcut.CONCRETE); + } TypePatternList args = arguments.resolveReferences(bindings); if (inAspect.crosscuttingMembers != null) { inAspect.crosscuttingMembers.exposeTypes(args.getExactTypes()); diff --git a/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java b/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java index 4c00603e9..e7d5ac8b9 100644 --- a/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java @@ -21,9 +21,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.aspectj.bridge.IMessage; import org.aspectj.util.FileUtil; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.Advice; +import org.aspectj.weaver.Checker; import org.aspectj.weaver.CrosscuttingMembers; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; @@ -121,6 +123,13 @@ public class CflowPointcut extends Pointcut { public Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) { + if (bindings.getEnclosingAdvice() instanceof Checker) { + // Enforce rule about which designators are supported in deow + inAspect.getWorld().showMessage(IMessage.ERROR, + "cflow"+(isBelow?"below":"")+"() pointcut designator cannot be used in declare statement", + bindings.getEnclosingAdvice().getSourceLocation(), null); + return Pointcut.makeMatchesNothing(Pointcut.CONCRETE); + } //make this remap from formal positions to arrayIndices IntMap entryBindings = new IntMap(); for (int i=0, len=freeVars.length; i < len; i++) { diff --git a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java index df4fdb6b5..6cb181329 100644 --- a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java @@ -22,6 +22,7 @@ import java.util.List; import org.aspectj.bridge.IMessage; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.Advice; +import org.aspectj.weaver.Checker; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedMember; @@ -146,6 +147,16 @@ public class IfPointcut extends Pointcut { private IfPointcut partiallyConcretized = null; public Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) { //System.err.println("concretize: " + this + " already: " + partiallyConcretized); + + if (bindings.getEnclosingAdvice() instanceof Checker) { + // Enforce rule about which designators are supported in deow + inAspect.getWorld().showMessage(IMessage.ERROR, + "if() pointcut designator cannot be used in declare statement", + bindings.getEnclosingAdvice().getSourceLocation(), + null); + return Pointcut.makeMatchesNothing(Pointcut.CONCRETE); + } + if (partiallyConcretized != null) { return partiallyConcretized; } @@ -153,7 +164,11 @@ public class IfPointcut extends Pointcut { partiallyConcretized = ret; if (bindings.directlyInAdvice()) { ShadowMunger advice = bindings.getEnclosingAdvice(); - ret.baseArgsCount = ((Advice)advice).getBaseParameterCount(); + if (advice instanceof Advice) { + ret.baseArgsCount = ((Advice)advice).getBaseParameterCount(); + } else { + ret.baseArgsCount = 0; + } ret.residueSource = advice.getPointcut().concretize(inAspect, ret.baseArgsCount, advice); } else { ResolvedPointcutDefinition def = bindings.peekEnclosingDefinitition(); diff --git a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java index f17a5a15c..814370f15 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java @@ -17,7 +17,9 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.bridge.IMessage; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.Checker; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; @@ -115,6 +117,14 @@ public class ThisOrTargetPointcut extends NameBindingPointcut { } public Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) { + if (bindings.getEnclosingAdvice() instanceof Checker) { + // Enforce rule about which designators are supported in deow + inAspect.getWorld().showMessage(IMessage.ERROR, + (isThis?"this":"target")+"() pointcut designator cannot be used in declare statement", + bindings.getEnclosingAdvice().getSourceLocation(), null); + return Pointcut.makeMatchesNothing(Pointcut.CONCRETE); + } + TypePattern newType = type.remapAdviceFormals(bindings); if (inAspect.crosscuttingMembers != null) { inAspect.crosscuttingMembers.exposeType(newType.getExactType()); |