Community
Participate
Working Groups
Today I found out the following. When writing an advice as... after() returning(Object o): staticinitialization(*) { System.out.println(o); } This advice is indeed executed every time a type returns from staticinitialization. However, since there is no returned object, o is bound to "null". I think this is inconsistent with the fact where we have something like: after() returning(T o): call(Object Foo.bar()) { System.out.println(o); } Here, AFAIK the advice would not execute in cases where the returned object is not an instance of T. Thus, I would propose that the first advice should only execute at joinpoints where a return value is available.
I've fixed this in the tree. If a join point kind has no return value, the returning(XXXX xxx) form no longer matches against it. Thus after() returning(Object obj) : no longer matches at the following join point kinds: * Constructor execution * preinitialization * initialization * staticinitialization * set * handler (but this was disallowed anyway) This change can only affect programs using returning(Object xx) since no other form would have matched at these join points anyway. Will close the report once fix is available in a published build.
fix now available