diff options
author | acolyer <acolyer> | 2004-03-19 20:48:01 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2004-03-19 20:48:01 +0000 |
commit | c298ef779c6430ca130ca6749b60818b71bd0275 (patch) | |
tree | 0bcfed374b6c778719206f15efc7df2f9e524ea4 /runtime/src | |
parent | 4907ede37a5688c7d4b35785bcf9b3da54c80c15 (diff) | |
download | aspectj-c298ef779c6430ca130ca6749b60818b71bd0275.tar.gz aspectj-c298ef779c6430ca130ca6749b60818b71bd0275.zip |
fix for Bugzilla Bug 54721
add this to API (Signature.getDeclaringTypeName())
Diffstat (limited to 'runtime/src')
8 files changed, 29 insertions, 13 deletions
diff --git a/runtime/src/org/aspectj/lang/Signature.java b/runtime/src/org/aspectj/lang/Signature.java index 91e2f00a2..ae21d65a3 100644 --- a/runtime/src/org/aspectj/lang/Signature.java +++ b/runtime/src/org/aspectj/lang/Signature.java @@ -92,4 +92,11 @@ public interface Signature { * @see java.lang.reflect.Member#getDeclaringClass */ Class getDeclaringType(); + + /** + * Returns the fully-qualified name of the declaring type. This is + * equivalent to calling getDeclaringType().getName(), but caches + * the result for greater efficiency. + */ + String getDeclaringTypeName(); } diff --git a/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java index 647fb6528..029d4e6de 100644 --- a/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/AdviceSignatureImpl.java @@ -45,7 +45,7 @@ class AdviceSignatureImpl extends CodeSignatureImpl implements AdviceSignature { buf.append(sm.makeModifiersString(getModifiers())); if (sm.includeArgs) buf.append(sm.makeTypeName(getReturnType())); if (sm.includeArgs) buf.append(" "); - buf.append(sm.makePrimaryTypeName(getDeclaringType())); + buf.append(sm.makePrimaryTypeName(getDeclaringType(),getDeclaringTypeName())); buf.append("."); buf.append(getName()); sm.addSignature(buf, getParameterTypes()); diff --git a/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java index a81d25831..c9576baaa 100644 --- a/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/ConstructorSignatureImpl.java @@ -32,7 +32,7 @@ class ConstructorSignatureImpl extends CodeSignatureImpl implements ConstructorS String toString(StringMaker sm) { StringBuffer buf = new StringBuffer(); buf.append(sm.makeModifiersString(getModifiers())); - buf.append(sm.makePrimaryTypeName(getDeclaringType())); + buf.append(sm.makePrimaryTypeName(getDeclaringType(),getDeclaringTypeName())); sm.addSignature(buf, getParameterTypes()); sm.addThrows(buf, getExceptionTypes()); return buf.toString(); diff --git a/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java index 4fbc7d2c8..b04f23525 100644 --- a/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/FieldSignatureImpl.java @@ -40,7 +40,7 @@ public class FieldSignatureImpl extends MemberSignatureImpl implements FieldSign buf.append(sm.makeModifiersString(getModifiers())); if (sm.includeArgs) buf.append(sm.makeTypeName(getFieldType())); if (sm.includeArgs) buf.append(" "); - buf.append(sm.makePrimaryTypeName(getDeclaringType())); + buf.append(sm.makePrimaryTypeName(getDeclaringType(),getDeclaringTypeName())); buf.append("."); buf.append(getName()); return buf.toString(); diff --git a/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java index f2e7d5b01..d7301d8ac 100644 --- a/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/InitializerSignatureImpl.java @@ -35,7 +35,7 @@ class InitializerSignatureImpl extends CodeSignatureImpl implements InitializerS String toString(StringMaker sm) { StringBuffer buf = new StringBuffer(); buf.append(sm.makeModifiersString(getModifiers())); - buf.append(sm.makePrimaryTypeName(getDeclaringType())); + buf.append(sm.makePrimaryTypeName(getDeclaringType(),getDeclaringTypeName())); buf.append("."); buf.append(getName()); return buf.toString(); diff --git a/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java index b2652cc79..1ec8c6914 100644 --- a/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/MethodSignatureImpl.java @@ -43,7 +43,7 @@ class MethodSignatureImpl extends CodeSignatureImpl implements MethodSignature { buf.append(sm.makeModifiersString(getModifiers())); if (sm.includeArgs) buf.append(sm.makeTypeName(getReturnType())); if (sm.includeArgs) buf.append(" "); - buf.append(sm.makePrimaryTypeName(getDeclaringType())); + buf.append(sm.makePrimaryTypeName(getDeclaringType(),getDeclaringTypeName())); buf.append("."); buf.append(getName()); sm.addSignature(buf, getParameterTypes()); diff --git a/runtime/src/org/aspectj/runtime/reflect/SignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/SignatureImpl.java index d5426eeaa..b010acf26 100644 --- a/runtime/src/org/aspectj/runtime/reflect/SignatureImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/SignatureImpl.java @@ -22,6 +22,7 @@ import java.util.StringTokenizer; abstract class SignatureImpl implements Signature { int modifiers = -1; String name; + String declaringTypeName; Class declaringType; SignatureImpl(int modifiers, String name, Class declaringType) { @@ -48,7 +49,12 @@ abstract class SignatureImpl implements Signature { if (declaringType == null) declaringType = extractType(2); return declaringType; } - + public String getDeclaringTypeName() { + if (declaringTypeName == null) { + declaringTypeName = getDeclaringType().getName(); + } + return declaringTypeName; + } String fullTypeName(Class type) { if (type == null) return "ANONYMOUS"; diff --git a/runtime/src/org/aspectj/runtime/reflect/StringMaker.java b/runtime/src/org/aspectj/runtime/reflect/StringMaker.java index a63ae9d6b..e014defb4 100644 --- a/runtime/src/org/aspectj/runtime/reflect/StringMaker.java +++ b/runtime/src/org/aspectj/runtime/reflect/StringMaker.java @@ -81,22 +81,25 @@ class StringMaker { return name.substring(dot+1); } - String makeTypeName(Class type, boolean shortName) { + String makeTypeName(Class type, String typeName, boolean shortName) { if (type == null) return "ANONYMOUS"; - if (type.isArray()) return makeTypeName(type.getComponentType(), shortName) + "[]"; + if (type.isArray()) { + Class componentType = type.getComponentType(); + return makeTypeName(componentType, componentType.getName(), shortName) + "[]"; + } if (shortName) { - return stripPackageName(type.getName()).replace('$', '.'); + return stripPackageName(typeName).replace('$', '.'); } else { - return type.getName().replace('$', '.'); + return typeName.replace('$', '.'); } } public String makeTypeName(Class type) { - return makeTypeName(type, shortTypeNames); + return makeTypeName(type, type.getName(),shortTypeNames); } - public String makePrimaryTypeName(Class type) { - return makeTypeName(type, shortPrimaryTypeNames); + public String makePrimaryTypeName(Class type, String typeName) { + return makeTypeName(type, typeName, shortPrimaryTypeNames); } public void addTypeNames(StringBuffer buf, Class[] types) { |