Project: AspectJ
Bug 74952 before,after !(cflow(within(Trace*))) prints nothing
Reported: 2004-09-24 11:04:58 | Status: resolved fixed

Reference: "cflow(within(C)) vs (within(C)||cflowbelow(within(C)) in aspectj-users mailing list. The aspect TraceClass below doesn't print any message when the pointcut is defined to "!cflow(within(Trace*))". The other defintion "!(within(Trace*) || cflowbelow(within(Trace*)))" works fine. Wes Isberg in his reply explained that cflow should never be used alone but he thought "there is a bug or two in here" class SomeClass { static public void main (String [] args) { } } // SomeClass aspect TraceClass { // members static private int level = 0; static private void offset() { int i; for (i = 0; i < level; ++i) { System.out.print(" "); } } // offset pointcut pc() : !cflow(within(Trace*)) // !(within(Trace*) || cflowbelow(within(Trace*))) ; before () : pc() { offset(); System.out.println("-> " + thisJoinPoint); ++level; } after () : pc() { --level; offset(); System.out.println("<- " + thisJoinPoint); } } // TraceClass In order to try to figure out what is happening within TraceClass, I added a second aspect, TraceTrace, just to trace TraceClass. aspect TraceTrace { // members static private int level = 0; static private void offset() { int i; for (i = 0; i < level; ++i) { System.out.print(" "); } } // offset pointcut pc() : within(TraceClass); before () : pc() { offset(); System.out.println("=> " + thisJoinPoint); ++level; } after () : pc() { --level; offset(); System.out.println("<= " + thisJoinPoint); } } // TraceTrace Here is what TraceTrace prints when TraceClass uses "!cflow(within(Trace*))" => staticinitialization(TraceClass.<clinit>) => set(int TraceClass.level) <= set(int TraceClass.level) => preinitialization(TraceClass()) => initialization(TraceClass()) => execution(TraceClass()) <= execution(TraceClass()) <= initialization(TraceClass()) <= staticinitialization(TraceClass.<clinit>) The after advice is not executed for preinitialization.

Files changed in fix:
tests/bugs/WhatsGoingOn.java tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java weaver/src/org/aspectj/weaver/bcel/BcelShadow.java