[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| [aspectj-users] Avoid toString and hashCode exec/call being adviced | 
Hello all,
this is going to be a long one, so please bear with me. I can assure you that I've searched the net for a solution before writing this post
I'm using aspectj to follow the excecution of my flow, so this is how my advice looks like:
public aspect MyAspect{
	pointcut flowCut(): (call(* com.mycomp..*(..)) || call(com.mycomp..*.new(..)));
	pointcut notAspect(): !within(MyAspect);
	Object around(): notAspect() && flowCut(){
		Date startDate = new Date(System.currentTimeMillis());
		System.out.println("enter " + thisJoinPoint.getSignature()
				 + " caller=" + thisJoinPoint.getThis() + " calling method="
				+ thisEnclosingJoinPointStaticPart.getSignature());
		Object result = proceed();
		Date endDate = new Date(System.currentTimeMillis());
		System.out.println("exit " + thisJoinPoint.getSignature() + "; caller="
				+ thisJoinPoint.getThis() + "; calling method=" 
                                + thisEnclosingJoinPointStaticPart.getSignature()
				+ "; result: " + result + "; elapsed "
				+ (endDate.getTime() - startDate.getTime()) + " millisecs");
		return result;
	}
}
I'm using "caller="+ thisJoinPoint.getThis()
 because i want to know the specific instance of the caller. now my problem is that if one of my classes, under com.mycomp..* overrides the toString method, i don't get the instance number and the toString is activated, resulting in stack overflow.
I haven't managed to figure yet how the hashCode method is activated, but after I commented out all the toSring implementations, I started getting stack over flows that narroed down again to string builder and toString calls
So my question is
- what changes are needed to my pointcuts definitions so I'll be able to avoid the recursive calls?
- is there a better way to know who is the calling object?
View this message in context: 
Avoid toString and hashCode exec/call being adviced
Sent from the 
AspectJ - users mailing list archive at Nabble.com.