Bug 103157 - after returning should not bind "null" as return value
Summary: after returning should not bind "null" as return value
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M3   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 1.5.0RC1   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-08 09:13 EDT by Eric Bodden CLA
Modified: 2005-11-23 10:02 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Bodden CLA 2005-07-08 09:13:23 EDT
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.
Comment 1 Adrian Colyer CLA 2005-11-23 07:46:36 EST
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.
Comment 2 Adrian Colyer CLA 2005-11-23 10:02:23 EST
fix now available