From c439e326284d2ffdf4898a50a3d0d5f6a6e99ef1 Mon Sep 17 00:00:00 2001 From: acolyer Date: Tue, 8 Nov 2005 18:12:37 +0000 Subject: fix for pr104220 - poor toString implementations for adviceexecution join points. --- runtime/src/org/aspectj/lang/JoinPoint.java | 2 +- .../aspectj/runtime/reflect/AdviceSignatureImpl.java | 20 ++++++++++++++++---- .../src/org/aspectj/runtime/reflect/StringMaker.java | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/src/org/aspectj/lang/JoinPoint.java b/runtime/src/org/aspectj/lang/JoinPoint.java index 5640786ba..a32e995cc 100644 --- a/runtime/src/org/aspectj/lang/JoinPoint.java +++ b/runtime/src/org/aspectj/lang/JoinPoint.java @@ -177,6 +177,6 @@ public interface JoinPoint { static String INITIALIZATION = "initialization"; static String EXCEPTION_HANDLER = "exception-handler"; - static String ADVICE_EXECUTION = "advice-execution"; //??? consider this vs. pcd + static String ADVICE_EXECUTION = "adviceexecution"; } diff --git a/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java index 6bf899a22..a6fbc097b 100644 --- a/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java @@ -15,6 +15,7 @@ package org.aspectj.runtime.reflect; import java.lang.reflect.Method; +import java.util.StringTokenizer; import org.aspectj.lang.reflect.AdviceSignature; @@ -43,19 +44,30 @@ class AdviceSignatureImpl extends CodeSignatureImpl implements AdviceSignature { } protected String createToString(StringMaker sm) { - //XXX this signature needs a lot of work - StringBuffer buf = new StringBuffer("ADVICE: "); - buf.append(sm.makeModifiersString(getModifiers())); + StringBuffer buf = new StringBuffer(); +// buf.append(sm.makeModifiersString(getModifiers())); if (sm.includeArgs) buf.append(sm.makeTypeName(getReturnType())); if (sm.includeArgs) buf.append(" "); buf.append(sm.makePrimaryTypeName(getDeclaringType(),getDeclaringTypeName())); buf.append("."); - buf.append(getName()); + buf.append(toAdviceName(getName())); sm.addSignature(buf, getParameterTypes()); sm.addThrows(buf, getExceptionTypes()); return buf.toString(); } + private String toAdviceName(String methodName) { + if (methodName.indexOf('$') == -1) return methodName; + StringTokenizer strTok = new StringTokenizer(methodName,"$"); + while (strTok.hasMoreTokens()) { + String token = strTok.nextToken(); + if ( token.startsWith("before") || + token.startsWith("after") || + token.startsWith("around") ) return token; + } + return methodName; + } + /* (non-Javadoc) * @see org.aspectj.runtime.reflect.MemberSignatureImpl#createAccessibleObject() */ diff --git a/runtime/src/org/aspectj/runtime/reflect/StringMaker.java b/runtime/src/org/aspectj/runtime/reflect/StringMaker.java index a2a1122c0..941bc822f 100644 --- a/runtime/src/org/aspectj/runtime/reflect/StringMaker.java +++ b/runtime/src/org/aspectj/runtime/reflect/StringMaker.java @@ -16,6 +16,8 @@ package org.aspectj.runtime.reflect; import java.lang.reflect.Modifier; +import org.aspectj.lang.JoinPoint; + class StringMaker { boolean shortTypeNames = true; boolean includeArgs = true; -- cgit v1.2.3