[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Capturing multiple return values from recursive calls

What happens with an execution pointcut instead of a call pointcut ?
 
 
Jean-Louis Pasturel

-----Message d'origine-----
De : aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] De la part de Dinkar Rao
Envoyé : mercredi 2 septembre 2009 10:21
À : aspectj-users@xxxxxxxxxxx
Objet : [aspectj-users] Capturing multiple return values from recursive
calls


Hi Folks,

Need some help with AspectJ. How can I capture return values from recursive
calls ? I want not only the returned value from the top level method call in
the stack, but also link the values from the intermediate method calls. For
example, given this simple method:

    public int fact(int val) {
        if (val > 0) {
            return val * fact(val - 1);
        }
        else {
            return 1;
        }
    }

I can write an aspect that gets me the returned values from each call. 

    public pointcut FactCall() :
        call(public int fact(int));
    
    after() returning(int f) :
        FactCall() {
            System.out.println("returned = " + f);
        }

 So for fact(4), I get the returned values from the top-level call as 1, 1,
2, 6, 24.

But what I really want to do is to capture the return values from the top 2
(or top n) recursive method calls, i.e. something that links

1 => 1
1 => 2
2 => 6
6 => 24

Any suggestions on how to do this ?

Thanks,
Dinkar

-- 
View this message in context:
http://www.nabble.com/Capturing-multiple-return-values-from-recursive-calls-
tp25253444p25253444.html
Sent from the AspectJ - users mailing list archive at Nabble.com.

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



*********************************
This message and any attachments (the "message") are confidential and intended solely for the addressees. 
Any unauthorised use or dissemination is prohibited.
Messages are susceptible to alteration. 
France Telecom Group shall not be liable for the message if altered, changed or falsified.
If you are not the intended addressee of this message, please cancel it immediately and inform the sender.
********************************