Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Infinite advice call problem

Title: RE: [aspectj-users] Infinite advice call problem

Hi Robert

within refers to code that is literally inside your aspect. You don't have any calls to new
in Constructor, only a call to clone. In order to capture the _control flow_ through clone to new,
you need to use cflow (or to be precise !cflow).

        !within(Constructor) {
        !cflow(Constructor) {
should do the trick.


-----Original Message-----
From: Robert Wenner [mailto:robert@xxxxxxxxxx]
Sent: Tuesday January 07, 2003 4:14 AM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] Infinite advice call problem


I have the problem of infinite advice calls as described in FAQ item   
11.1; running the program below crashes the VM with a memory fault
(hence the class name).

According to the FAQ answer I could use after returning instead of
plain after to handle exceptions different from normal method
execution, or I could use !within(theAspect). Neither works for me,
i.e. neither changes the program behaviour.

I understand that the after returning does not have any impact on the
sample code as nothing is thrown.
But why doesnt !within work? Is this a problem due to indirect

What am I missing?

Thanks in advance,


class MemoryFault {
    public static void main(String args[]) {
        MemoryFault mf = new MemoryFault();

    public Object clone() {
        return new MemoryFault();

aspect Constructor {
    after(MemoryFault mf):
        target(mf) &&
        execution( &&
        !within(Constructor) {
        // System.out.println("In after() advice");
        MemoryFault other = (MemoryFault) mf.clone();
aspectj-users mailing list

Back to the top