Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] java.lang.StackOverflowError

Hello Calvin,

I just tried to run example in section 5.5.1 with AspectJ 1.2 
and it seems to work fine. 

Can you provide the other source files (unless you are trying
with the shopping cart example in the chapter) so that I can 
reproduce the problem?

Thanks.

-Ramnivas

--- Calvin Smith <Calvin@xxxxxxxxxxx> wrote:
> Hi,
> 
> I'm just getting started with AspectJ and am having trouble getting a
> simple tracing aspect from "AspectJ in Action" to work correctly.
> 
> Here is the complete aspect (which was exactly cut and pasted from
> the
> downloaded source code for the book, with the exception of changing
> the
> aspect's name):
> 
> import org.aspectj.lang.*;
> 
> public aspect TracerAspect {
>     
>     pointcut traceMethods() : 
>         (execution(* *.*(..))|| execution(*.new(..))) 
>         && !within(TracerAspect); 
> 
>     before() : traceMethods() && !execution(String *.toString()) {
>     	Signature sig = thisJoinPointStaticPart.getSignature();
>     	System.err.println("Entering ["
>     			   + sig.getDeclaringType().getName() + "."
>     			   + sig.getName() + "]"
>     			   + createParameterMessage(thisJoinPoint));
>     }
> 
>     private String createParameterMessage(JoinPoint joinPoint) {
>     	StringBuffer paramBuffer = new StringBuffer("\n\t[This: ");
>     	paramBuffer.append(joinPoint.getThis());
>     	Object[] arguments = joinPoint.getArgs();
>     	paramBuffer.append("]\n\t[Args: (");
>     	for (int length = arguments.length, i = 0; i < length; ++i) {
>     	    Object argument = arguments[i];
>     	    paramBuffer.append(argument);
>     	    if (i != length-1) {
>     	        paramBuffer.append(',');
>     	    }
>     	}
>     	paramBuffer.append(")]");
> 	    return paramBuffer.toString();
>     }
> }
> 
> The error I get is java.lang.StackOverflowError, with no stack trace.
> This sounds like the infinite recursion problem that
> "!execution(String
> *.toString())" was supposed to prevent, I know that the AJIA was
> written
> for AspectJ1.1, and I'm using 1.2, but the documentation said that
> the
> AspectJ language was not changed at all between these two versions,
> so
> I'm not sure what's going on, unless there's an error in the source
> code
> for AJIA.
> 
> Does the above aspect look obviously wrong? Are there any differences
> between 1.1 and 1.2 that could account for this behavior?
> 
> Thanks for any assistance,
> 
> Calvin
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users



	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 


Back to the top