[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] java.lang.StackOverflowError -- Pointcut written incorrectly?
|
Hello --
I am getting a java.lang.StackOverflowError when attempting to trace using the following
aspect:
note that on line 15 (the before() rule) I have the following:
!execution(String *.toString())
-- which is designed to prevent this type of problem from occurring. It didn't help.
I added the rule:
&& !execution(StringBuffer *.append(..))
hoping that would help things too. It didn't.
I am going to assume the worse, which is that I have miscoded this, and this is simply a
case of 'smoke in the cockpit'. So any and all help is greatly appreciated.
Thanks in advance.
-Michael
2004-06-23 09:10 Page 1
1 // Listing 2.9 LogAndTraceAspect.java
2
3 import org.apache.log4j.*;
4 import org.aspectj.lang.*;
5 public aspect LogAndTraceAspect {
6 private Logger logger = Logger.getLogger("trace");
7
8 LogAndTraceAspect() {
9 logger.setLevel(Level.ALL);
10 }
11
12 pointcut traceMethods() :
13 (execution(* *.*(..)) || execution(*.new(..)))&& !within(LogAndTraceAspect ||
java..* || javax..*);
14
15 before() : traceMethods() && !execution(String *.toString())&&
!execution(StringBuffer StringBuffer.append(..)){
16 Signature sig = thisJoinPointStaticPart.getSignature();
17 logger.log(Level.INFO, "Entering ["
18 + sig.getDeclaringType().getName() + "."
19 + sig.getName() +"]"
20 + createParameterMsg(thisJoinPoint)
21 );
22 }
23
24 after() : traceMethods() {
25 logger.log(Level.INFO, "Exiting ["+ thisJoinPoint + "]");
26 }
27
28 pointcut logMethodExceptions() :
29 call(* *.*(..)) && !within(LogAndTraceAspect);
30
31 after() throwing (Throwable t) : logMethodExceptions() {
32 if (logger.isEnabledFor(Level.ERROR)){
33 Signature sig = thisJoinPointStaticPart.getSignature();
34 logger.log(Level.ERROR, "Exception encountered ["
35 + sig.getDeclaringType().getName() + "."
36 + sig.getName() +"]", t);
37 }
38 }
39
40 private String createParameterMsg(JoinPoint jp){
41 StringBuffer paramBuffer = new StringBuffer("\n\t[This: ");
42 Object[] arguments = jp.getArgs();
43 paramBuffer.append(jp.getThis());
44 paramBuffer.append("]\n\t[Args: (");
45 for (int length = arguments.length, i=0;i < length; ++i){
46 Object argument = arguments[i];
47 paramBuffer.append(argument);
48 if (i != length-1) {
49 paramBuffer.append(',');
50 }
51 }
52 paramBuffer.append(")]");
53 return paramBuffer.toString();
54 }
55 }
56
=====
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail