]> source.dussan.org Git - aspectj.git/commitdiff
Fix for bugzilla bug 71393:
authorehilsdal <ehilsdal>
Mon, 23 Aug 2004 02:51:10 +0000 (02:51 +0000)
committerehilsdal <ehilsdal>
Mon, 23 Aug 2004 02:51:10 +0000 (02:51 +0000)
  Specify how does args pointcut collect context for pointcuts which are used in cflow

docs/progGuideDB/semantics.xml

index b7dd334453149545bf7449a9431a9b7484a592e5..3c1c8fe3280a3a9d88c942cb6f571e25b054ed47 100644 (file)
         argument was an <literal>int</literal>, then the value passed to
         advice will be of type <literal>java.lang.Integer</literal>.
       </para>
+
     </sect2>
 
     <sect2>
           picked out by <replaceable>Pointcut</replaceable>.
         </para>
 
+        <sect4>
+          <title>Context exposure from control flows</title>
+
+          <para>
+            The <literal>cflow</literal> and
+            <literal>cflowbelow</literal> pointcuts may expose context
+            state through enclosed <literal>this</literal>,
+            <literal>target</literal>, and <literal>args</literal>
+            pointcuts. 
+          </para>
+
+          <para>
+           Anytime such state is accessed, it is accessed through the
+           <emphasis>most recent</emphasis> control flow that
+           matched.   So the "current arg" that would be printed by
+           the following program is zero, even though it is in many
+           control flows.
+          </para>
+
+<programlisting>
+class Test {
+    public static void main(String[] args) {
+        fact(5);
+    }
+    static int fact(int x) {
+        if (x == 0) {
+            System.err.println("bottoming out");
+            return 1;
+        }
+        else return x * fact(x - 1);
+    }
+}
+
+aspect A {
+    pointcut entry(int i): call(int fact(int)) <![CDATA[&&]]> args(i);
+    pointcut writing(): call(void println(String)) <![CDATA[&&]]> ! within(A);
+    
+    before(int i): writing() <![CDATA[&&]]> cflow(entry(i)) {
+        System.err.println("Current arg is " + i);
+    }
+}
+</programlisting>
+
+          <para>
+            It is an error to expose such state through
+            <emphasis>negated</emphasis> control flow pointcuts, such
+            as within <literal>!
+            cflowbelow(<replaceable>P</replaceable>)</literal>.
+          </para>
+
+        </sect4>
       </sect3>
 
       <sect3>