</compile>
</ajc-test>
+ <ajc-test dir="bugs" pr="51320"
+ title="ClasscastException on concretization of if(false)">
+ <compile files="DeclareSoftDynamicPCDs.java">
+
+ <!-- These are the illegal PCDs against a deow -->
+ <message kind="error" line="27" text="if() pointcut designator cannot be used"/>
+ <message kind="error" line="29" text="if() pointcut designator cannot be used"/>
+
+ <message kind="error" line="31" text="cflow() pointcut designator cannot be used"/>
+ <message kind="error" line="33" text="cflow() pointcut designator cannot be used"/>
+
+ <message kind="error" line="35" text="cflowbelow() pointcut designator cannot be used"/>
+ <message kind="error" line="37" text="cflowbelow() pointcut designator cannot be used"/>
+
+ <message kind="error" line="39" text="this() pointcut designator cannot be used"/>
+ <message kind="error" line="41" text="this() pointcut designator cannot be used"/>
+
+ <message kind="error" line="43" text="target() pointcut designator cannot be used"/>
+ <message kind="error" line="45" text="target() pointcut designator cannot be used"/>
+
+ <message kind="error" line="47" text="args() pointcut designator cannot be used"/>
+ <message kind="error" line="49" text="args() pointcut designator cannot be used"/>
+
+ </compile>
+ </ajc-test>
+
</suite>
--- /dev/null
+/*
+ * From:
+ *
+ * http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/progguide/semantics-declare.html#d0e6499
+ *
+ * Pointcuts that appear inside of declare forms have certain restrictions.
+ * Like other pointcuts, these pick out join points, but they do so in a
+ * way that is statically determinable.
+ *
+ * Consequently, such pointcuts may not include, directly or indirectly
+ * (through user-defined pointcut declarations) pointcuts that discriminate
+ * based on dynamic (runtime) context. Therefore, such pointcuts may not be
+ * defined in terms of
+ *
+ * cflow
+ * cflowbelow
+ * this
+ * target
+ * args
+ * if
+ *
+ * all of which can discriminate on runtime information.
+ */
+
+public aspect DeclareSoftDynamicPCDs {
+
+ declare soft : MyException:if(true) ;
+ pointcut p(): if(false);
+ declare soft : MyException: p() ;
+
+ declare soft : MyException:cflow(execution(* main(..)));
+ pointcut p2(): cflow(execution(* main(..)));
+ declare soft : MyException:p2();
+
+ declare soft : MyException:cflowbelow(execution(* main(..)));
+ pointcut p3(): cflowbelow(execution(* main(..)));
+ declare soft : MyException:p3();
+
+ declare soft : MyException: this(Object);
+ pointcut p4(): this(Object);
+ declare soft : MyException:p4();
+
+ declare soft : MyException:target(Object);
+ pointcut p5(): target(Object);
+ declare soft : MyException:p5();
+
+ declare soft : MyException:args(Object);
+ pointcut p6(): args(Object);
+ declare soft : MyException:p6();
+
+ class MyException extends Exception {
+ }
+
+ public static void main(String[] args) {
+ System.err.println("In main!");
+ }
+
+}
\ No newline at end of file
import java.util.Map;
import java.util.Set;
-import org.aspectj.weaver.bcel.BcelTypeMunger;
import org.aspectj.weaver.patterns.DeclareParents;
/**
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;
public Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) {
- if (bindings.getEnclosingAdvice() instanceof Checker) {
- // Enforce rule about which designators are supported in deow
+ if (isDeclare(bindings.getEnclosingAdvice())) {
+ // Enforce rule about which designators are supported in declare
inAspect.getWorld().showMessage(IMessage.ERROR,
"args() pointcut designator cannot be used in declare statement",
bindings.getEnclosingAdvice().getSourceLocation(), null);
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;
public Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) {
- if (bindings.getEnclosingAdvice() instanceof Checker) {
- // Enforce rule about which designators are supported in deow
+ if (isDeclare(bindings.getEnclosingAdvice())) {
+ // Enforce rule about which designators are supported in declare
inAspect.getWorld().showMessage(IMessage.ERROR,
"cflow"+(isBelow?"below":"")+"() pointcut designator cannot be used in declare statement",
bindings.getEnclosingAdvice().getSourceLocation(), null);
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;
import org.aspectj.weaver.ResolvedTypeX;
import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.ShadowMunger;
-import org.aspectj.weaver.ast.*;
import org.aspectj.weaver.ast.Expr;
import org.aspectj.weaver.ast.Literal;
import org.aspectj.weaver.ast.Test;
+import org.aspectj.weaver.ast.Var;
public class IfPointcut extends Pointcut {
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
+ if (isDeclare(bindings.getEnclosingAdvice())) {
+ // Enforce rule about which designators are supported in declare
inAspect.getWorld().showMessage(IMessage.ERROR,
"if() pointcut designator cannot be used in declare statement",
bindings.getEnclosingAdvice().getSourceLocation(),
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;
}
public Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) {
- if (bindings.getEnclosingAdvice() instanceof Checker) {
- // Enforce rule about which designators are supported in deow
+ if (isDeclare(bindings.getEnclosingAdvice())) {
+ // Enforce rule about which designators are supported in declare
inAspect.getWorld().showMessage(IMessage.ERROR,
(isThis?"this":"target")+"() pointcut designator cannot be used in declare statement",
bindings.getEnclosingAdvice().getSourceLocation(), null);