Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Help with at aspect declare error stack overflow

Hi,

I am getting this weird bug when trying to define an error with @DeclareError on a method. When compiling, the first time i'm getting a stack overflow error from aspectj and the second time everything compiles just fine. We are in LTW. For example, if I do

$ mvn clean
$ mvn jetty:run <---- this will fail and create an ajcore (stack overflow)
$ mvn jetty:run <---- now it works fine

Now, here is the bug I found and how I fixed it... although I don't  understand why it didn't work in the first place.

Here is the NOT-working aspect :

#########################
public class OwnershipSecurityAspect {

    @Pointcut("call(public void ca..setOwner(..)) && !within(ca..OwnershipSecurityAspect) && !within(ca..*Test)")
    public void myPcut() {};

    @DeclareError("myPcut()")
    public static final String securityError = "An advice already exists for setting an owner";
}
########################

So that creates the error, but if i put the PC declaration inside the declareError like so :

#########################
public class OwnershipSecurityAspect {

    @DeclareError("call(public void ca..setOwner(..)) && !within(ca..OwnershipSecurityAspect) && !within(ca..*Test)")
    public static final String securityError = "An advice already exists for setting an owner";
}
##########################

Now everything works fine.

However, the first method should work too, it's even the example in the doc : http://www.eclipse.org/aspectj/doc/next/aspectj5rt-api/org/aspectj/lang/annotation/DeclareError.html

Also note that the setOwner() method IS called inside this aspect... so I thought it was infinite recursion... but I didn't even change the pointcut definition, so I don't think this is the issue at hand here...

Thanks in advance for the help,
Jni

Back to the top