Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Advise a method to return?

Hi all,

Is it possible to use an aspect to force a method to return?
Imagine many occurrences of the doStuff() / checkNeedToReturn() combo below:

  void foo()
  {

    // ...

    blah.doStuff();

    // Any call to *.doStuff() may change some state such that
    // the caller must return.
    // Can the following block be encapsulated in an aspect?

    if ( checkNeedToReturn() ) {
      return;
    }

    // ...

  }

I cannot establish whether or not advice can force a caller to return.

  after() : call (* *.doStuff())
  {
    if ( checkNeedToReturn() ) {
      // Some method has called doStuff() and now needs to return.
      // Can we force that method to return from here?
      return; // this just returns from the advice
    }
  }


I'd rather avoid using exceptions since this is not an unusual execution
path.

Any ideas welcome.

Cheers,
Robin

-- 
View this message in context: http://www.nabble.com/Advise-a-method-to-return--tf3151815.html#a8739469
Sent from the AspectJ - users mailing list archive at Nabble.com.



Back to the top