From eb00b928a548f6ca64ab3a0f6ccfa57c38e80bec Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 4 Jun 2008 19:06:15 +0000 Subject: [PATCH] 231396: refactoring AspectJ: tidying up --- .../aspectj/weaver/JoinPointSignature.java | 4 -- weaver/src/org/aspectj/weaver/Member.java | 16 ++---- weaver/src/org/aspectj/weaver/MemberImpl.java | 49 +++---------------- .../org/aspectj/weaver/ResolvedMember.java | 5 +- .../aspectj/weaver/ResolvedMemberImpl.java | 4 +- .../org/aspectj/weaver/UnresolvedType.java | 34 +------------ 6 files changed, 18 insertions(+), 94 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/JoinPointSignature.java b/weaver/src/org/aspectj/weaver/JoinPointSignature.java index 8c89cde54..b6bb83b7e 100644 --- a/weaver/src/org/aspectj/weaver/JoinPointSignature.java +++ b/weaver/src/org/aspectj/weaver/JoinPointSignature.java @@ -308,10 +308,6 @@ public class JoinPointSignature implements ResolvedMember { return realMember.canBeParameterized(); } - public int getCallsiteModifiers() { - return realMember.getCallsiteModifiers(); - } - public String getExtractableName() { return realMember.getExtractableName(); } diff --git a/weaver/src/org/aspectj/weaver/Member.java b/weaver/src/org/aspectj/weaver/Member.java index a911722f7..3f4605e78 100644 --- a/weaver/src/org/aspectj/weaver/Member.java +++ b/weaver/src/org/aspectj/weaver/Member.java @@ -16,6 +16,9 @@ package org.aspectj.weaver; import java.util.Collection; import java.util.Iterator; +/** + * Abstract representation of a member within a type. + */ public interface Member extends Comparable { public static final Member[] NONE = new Member[0]; @@ -53,16 +56,12 @@ public interface Member extends Comparable { public UnresolvedType[] getParameterTypes(); - /** - * Return full signature, including return type, e.g. "()LFastCar;" for a signature without the return type, - * use getParameterSignature() - it is importnant to choose the right one in the face of covariance. + * Return full signature, including return type, e.g. "()LFastCar;". For a signature without the return type, + * use getParameterSignature() - it is important to choose the right one in the face of covariance. */ public String getSignature(); - /** - * All the signatures that a join point with this member as its signature has. - */ public Iterator getJoinPointSignatures(World world); public int getArity(); @@ -79,7 +78,6 @@ public interface Member extends Comparable { public int getModifiers(); - public boolean isStatic(); public boolean isInterface(); @@ -88,12 +86,9 @@ public interface Member extends Comparable { /** * Returns true iff the member is generic (NOT parameterized) - * For example, a method declared in a generic type */ public boolean canBeParameterized(); - public int getCallsiteModifiers(); - public String getExtractableName(); public AnnotationX[] getAnnotations(); @@ -102,7 +97,6 @@ public interface Member extends Comparable { public String getSignatureMakerName(); public String getSignatureType(); - public Collection/* ResolvedType */getDeclaringTypes(World world); diff --git a/weaver/src/org/aspectj/weaver/MemberImpl.java b/weaver/src/org/aspectj/weaver/MemberImpl.java index 4f9c4479b..66c0dc7b0 100644 --- a/weaver/src/org/aspectj/weaver/MemberImpl.java +++ b/weaver/src/org/aspectj/weaver/MemberImpl.java @@ -10,7 +10,6 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver; import java.lang.reflect.Modifier; @@ -20,14 +19,14 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; - public class MemberImpl implements Member { protected MemberKind kind; - protected String name; - protected UnresolvedType declaringType; + protected int modifiers; + protected String name; protected UnresolvedType returnType; + protected UnresolvedType declaringType; protected UnresolvedType[] parameterTypes; private final String signature; private String paramSignature; @@ -111,6 +110,7 @@ public class MemberImpl implements Member { * @param signature the JVM bytecode method signature string we want to break apart * @return a pair of UnresolvedType, UnresolvedType[] representing the return types and parameter types. */ + // OPTIMIZE move static util methods out into a memberutils class public static String typesToSignature(UnresolvedType returnType, UnresolvedType[] paramTypes, boolean useRawTypes) { StringBuffer buf = new StringBuffer(); buf.append("("); @@ -365,27 +365,14 @@ public class MemberImpl implements Member { public UnresolvedType getGenericReturnType() { return getReturnType(); } public UnresolvedType[] getGenericParameterTypes() { return getParameterTypes(); } - /* (non-Javadoc) - * @see org.aspectj.weaver.Member#getType() - */ - public UnresolvedType getType() { return returnType; } - /* (non-Javadoc) - * @see org.aspectj.weaver.Member#getName() - */ + public final UnresolvedType getType() { return returnType; } public String getName() { return name; } - /* (non-Javadoc) - * @see org.aspectj.weaver.Member#getParameterTypes() - */ public UnresolvedType[] getParameterTypes() { return parameterTypes; } - - + public String getSignature() { return signature; } public int getArity() { return parameterTypes.length; } - /* (non-Javadoc) - * @see org.aspectj.weaver.Member#getParameterSignature() - */ public String getParameterSignature() { if (paramSignature != null) return paramSignature; StringBuffer sb = new StringBuffer(); @@ -460,17 +447,10 @@ public class MemberImpl implements Member { return false; } - public final int getCallsiteModifiers() { - return modifiers & ~ Modifier.INTERFACE; - } - public int getModifiers() { return modifiers; } - /* (non-Javadoc) - * @see org.aspectj.weaver.Member#getExtractableName() - */ public final String getExtractableName() { // OPTIMIZE remove silly string compares for init - use kind==CTOR/STATIC_INITIALIZATION if (name.equals("")) return "init$"; @@ -478,21 +458,12 @@ public class MemberImpl implements Member { else return name; } - - /* (non-Javadoc) - * @see org.aspectj.weaver.Member#getAnnotations() - */ public AnnotationX[] getAnnotations() { throw new UnsupportedOperationException("You should resolve this member '"+this+"' and call getAnnotations() on the result..."); } // ---- fields 'n' stuff - - - /* (non-Javadoc) - * @see org.aspectj.weaver.Member#getDeclaringTypes(org.aspectj.weaver.World) - */ public Collection/*ResolvedType*/ getDeclaringTypes(World world) { ResolvedType myType = getDeclaringType().resolve(world); Collection ret = new HashSet(); @@ -574,11 +545,6 @@ public class MemberImpl implements Member { } - - - /* (non-Javadoc) - * @see org.aspectj.weaver.Member#getSignatureType() - */ public String getSignatureType() { MemberKind kind = getKind(); if (getName().equals("")) return "org.aspectj.lang.reflect.InitializerSignature"; @@ -790,9 +756,6 @@ public class MemberImpl implements Member { return buf.toString(); } - /* (non-Javadoc) - * @see org.aspectj.weaver.Member#getParameterNames(org.aspectj.weaver.World) - */ public String[] getParameterNames(World world) { ResolvedMember resolved = resolve(world); if (resolved == null) { diff --git a/weaver/src/org/aspectj/weaver/ResolvedMember.java b/weaver/src/org/aspectj/weaver/ResolvedMember.java index b3a23e0a8..2edeba6f2 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedMember.java +++ b/weaver/src/org/aspectj/weaver/ResolvedMember.java @@ -33,7 +33,8 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe public UnresolvedType[] getExceptions(); public ShadowMunger getAssociatedShadowMunger(); -//OPTIMIZE have param annotation (and anno default value) related stuff here rather than above + + //OPTIMIZE have param annotation (and anno default value) related stuff here rather than above // ??? true or false? public boolean isAjSynthetic(); @@ -41,6 +42,8 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe public boolean hasAnnotation(UnresolvedType ofType); + public AnnotationX[] getAnnotations(); + public ResolvedType[] getAnnotationTypes(); public void setAnnotationTypes(UnresolvedType[] annotationtypes); diff --git a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java index a4db3746f..e36f4bd77 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java +++ b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java @@ -981,7 +981,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno } // 'declaring' type - r.append(getGenericReturnType().toDebugString()); + r.append(getGenericReturnType().toString()); r.append(' '); // name @@ -997,7 +997,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno if (params.length != 0) { for (int i=0, len = params.length; i < len; i++) { if (i>0) r.append(", "); - r.append(params[i].toDebugString()); + r.append(params[i].toString()); if (parameterNamesExist) r.append(" ").append(parameterNames[i]); } } diff --git a/weaver/src/org/aspectj/weaver/UnresolvedType.java b/weaver/src/org/aspectj/weaver/UnresolvedType.java index f734a7c8b..79d6aa471 100644 --- a/weaver/src/org/aspectj/weaver/UnresolvedType.java +++ b/weaver/src/org/aspectj/weaver/UnresolvedType.java @@ -28,7 +28,7 @@ import org.aspectj.weaver.tools.Traceable; * A UnresolvedType represents a type to the weaver. It has a basic signature that knows * nothing about type variables, type parameters, etc.. UnresolvedTypes are resolved in some World * (a repository of types). When a UnresolvedType is resolved it turns into a - * ResolvedType which may be a primitive type, an array type or a ReferenceType. + * ResolvedType which may be a primitive type, or a ReferenceType. * ReferenceTypes may refer to simple, generic, parameterized or type-variable * based reference types. A ReferenceType is backed by a delegate that provides * information about the type based on some repository (currently either BCEL @@ -207,34 +207,6 @@ public class UnresolvedType implements Unresolved, Traceable, TypeVariableDeclar throw new UnsupportedOperationException("unable to parameterize unresolved type: " + signature); } - /** - * protected constructor for use only within UnresolvedType hierarchy. Use - * one of the UnresolvedType.forXXX static methods for normal creation of - * TypeXs. - * Picks apart the signature string to set the type kind and calculates the - * corresponding signatureErasure. A SIMPLE type created from a plain - * Java signature may turn into a GENERIC type when it is resolved. - * - * This method should never be called for a primitive type. (UnresolvedType. forSignature - * deals with those). - * - * @param signature in the form described in the class comment at the - * top of this file. - */ -// protected UnresolvedType(String aSignature) { -// this.signature = aSignature; -// -// -// } - - // ----------------------------- - // old stuff... - - - - /** - * @param signature the bytecode string representation of this Type - */ protected UnresolvedType(String signature) { super(); this.signature = signature; @@ -599,10 +571,6 @@ public class UnresolvedType implements Unresolved, Traceable, TypeVariableDeclar public String toString() { return getName(); // + " - " + getKind(); } - - public String toDebugString() { - return getName(); - } // ---- requires worlds -- 2.39.5