From 4d4b30fc8865354bb1224167fa83108208ad2aae Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 26 Apr 2010 23:41:21 +0000 Subject: [PATCH] improved annotation handling on ResolvedMemberImpl --- .../aspectj/weaver/JoinPointSignature.java | 6 +- .../src/org/aspectj/weaver/Member.java | 22 ++-- .../src/org/aspectj/weaver/MemberImpl.java | 14 +-- .../org/aspectj/weaver/ResolvedMember.java | 8 +- .../aspectj/weaver/ResolvedMemberImpl.java | 100 +++++++++--------- .../src/org/aspectj/weaver/ResolvedType.java | 1 + .../ReflectionBasedResolvedMemberImpl.java | 75 +++++++------ 7 files changed, 120 insertions(+), 106 deletions(-) diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java b/org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java index 0191591d5..70f58be9a 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java @@ -38,6 +38,8 @@ import org.aspectj.weaver.AjAttribute.EffectiveSignatureAttribute; */ public class JoinPointSignature implements ResolvedMember { + public static final JoinPointSignature[] EMPTY_ARRAY = new JoinPointSignature[0]; + private ResolvedMember realMember; private ResolvedType substituteDeclaringType; @@ -200,7 +202,7 @@ public class JoinPointSignature implements ResolvedMember { } public ResolvedMemberImpl parameterizedWith(UnresolvedType[] typeParameters, ResolvedType newDeclaringType, - boolean isParameterized, List aliases) { + boolean isParameterized, List aliases) { return realMember.parameterizedWith(typeParameters, newDeclaringType, isParameterized, aliases); } @@ -224,7 +226,7 @@ public class JoinPointSignature implements ResolvedMember { return realMember.resolve(world); } - public int compareTo(Object other) { + public int compareTo(Member other) { return realMember.compareTo(other); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/Member.java b/org.aspectj.matcher/src/org/aspectj/weaver/Member.java index 85e02ad9b..8134e8df2 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/Member.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/Member.java @@ -1,27 +1,26 @@ /* ******************************************************************* - * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). - * 2005 Contributors + * Copyright (c) 2002-2010 * All rights reserved. * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 * which accompanies this distribution and is available at * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * PARC initial implementation - * AMC extracted as interface * ******************************************************************/ package org.aspectj.weaver; import java.util.Collection; /** - * Abstract representation of a member within a type. + * Abstract representation of a member (field/constructor/method) within a type. + * + * @author PARC + * @author Adrian Colyer + * @author Andy Clement */ -public interface Member extends Comparable { +public interface Member extends Comparable { public static final Member[] NONE = new Member[0]; - + public static final MemberKind METHOD = new MemberKind("METHOD", 1); public static final MemberKind FIELD = new MemberKind("FIELD", 2); public static final MemberKind CONSTRUCTOR = new MemberKind("CONSTRUCTOR", 3); @@ -45,10 +44,13 @@ public interface Member extends Comparable { public UnresolvedType getDeclaringType(); public UnresolvedType[] getParameterTypes(); + public UnresolvedType[] getGenericParameterTypes(); public UnresolvedType getType(); + public UnresolvedType getReturnType(); + public UnresolvedType getGenericReturnType(); /** @@ -86,6 +88,6 @@ public interface Member extends Comparable { public ResolvedMember resolve(World world); - public int compareTo(Object other); + public int compareTo(Member other); } \ No newline at end of file diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/MemberImpl.java b/org.aspectj.matcher/src/org/aspectj/weaver/MemberImpl.java index b34c34946..64ae458d2 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/MemberImpl.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/MemberImpl.java @@ -155,7 +155,7 @@ public class MemberImpl implements Member { private static Object[] signatureToTypes(String sig) { boolean hasParameters = sig.charAt(1) != ')'; if (hasParameters) { - List l = new ArrayList(); + List l = new ArrayList(); int i = 1; boolean hasAnyAnglies = sig.indexOf('<') != -1; while (true) { @@ -211,7 +211,7 @@ public class MemberImpl implements Member { l.add(UnresolvedType.forSignature(sig.substring(start, i))); } } - UnresolvedType[] paramTypes = (UnresolvedType[]) l.toArray(new UnresolvedType[l.size()]); + UnresolvedType[] paramTypes = l.toArray(new UnresolvedType[l.size()]); UnresolvedType returnType = UnresolvedType.forSignature(sig.substring(i + 1, sig.length())); return new Object[] { returnType, paramTypes }; } else { @@ -305,8 +305,8 @@ public class MemberImpl implements Member { return hashCode; } - public int compareTo(Object other) { - Member o = (Member) other; + public int compareTo(Member other) { + Member o = other; int i = getName().compareTo(o.getName()); if (i != 0) { return i; @@ -483,14 +483,14 @@ public class MemberImpl implements Member { return b; } - private boolean walkUpStatic(Collection acc, ResolvedType curr) { + private boolean walkUpStatic(Collection acc, ResolvedType curr) { if (curr.lookupMemberNoSupers(this) != null) { acc.add(curr); return true; } else { boolean b = false; - for (Iterator i = curr.getDirectSupertypes(); i.hasNext();) { - b |= walkUpStatic(acc, (ResolvedType) i.next()); + for (Iterator i = curr.getDirectSupertypes(); i.hasNext();) { + b |= walkUpStatic(acc, i.next()); } if (!b && curr.isParameterizedType()) { b = walkUpStatic(acc, curr.getGenericType()); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java index 93d1361a5..ffeedbbc3 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java @@ -126,9 +126,7 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe public boolean equalsApartFromDeclaringType(Object other); // return a resolved member in which all type variables in the signature of - // this - // member have been replaced with the given bindings. - // the isParameterized flag tells us whether we are creating a raw type + // this member have been replaced with the given bindings. the isParameterized flag tells us whether we are creating a raw type // version or not // if isParameterized List will turn into List (for example), // but if !isParameterized List will turn into List. @@ -140,7 +138,7 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe // this is used for processing ITDs that share type variables with their // target generic type public ResolvedMemberImpl parameterizedWith(UnresolvedType[] typeParameters, ResolvedType newDeclaringType, - boolean isParameterized, List aliases); + boolean isParameterized, List aliases); public void setTypeVariables(TypeVariable[] types); @@ -154,7 +152,7 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe public void evictWeavingState(); - public ResolvedMember parameterizedWith(Map m, World w); + public ResolvedMember parameterizedWith(Map m, World w); public boolean isDefaultConstructor(); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java index 3890488d0..c63c8a09c 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java @@ -1,15 +1,11 @@ /* ******************************************************************* - * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). + * Copyright (c) 2002-2010 Contributors * All rights reserved. * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 * which accompanies this distribution and is available at * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver; import java.io.DataOutputStream; @@ -26,31 +22,35 @@ import java.util.Set; import org.aspectj.bridge.ISourceLocation; /** - * This is the declared member, i.e. it will always correspond to an actual method/... declaration + * Represent a resolved member. Components of it are expected to exist. This member will correspond to a real member *unless* it is + * being used to represent the effect of an ITD. + * + * @author PARC + * @author Andy Clement */ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, AnnotatedElement, TypeVariableDeclaringElement, ResolvedMember { private String[] parameterNames = null; protected UnresolvedType[] checkedExceptions = UnresolvedType.NONE; + /** * if this member is a parameterized version of a member in a generic type, then this field holds a reference to the member we * parameterize. */ protected ResolvedMember backingGenericMember = null; - protected Set annotationTypes = null; + protected AnnotationAJ[] annotations = null; + protected ResolvedType[] annotationTypes = null; + protected AnnotationAJ[][] parameterAnnotations = null; protected ResolvedType[][] parameterAnnotationTypes = null; // Some members are 'created' to represent other things (for example ITDs). - // These - // members have their annotations stored elsewhere, and this flag indicates - // that is - // the case. It is up to the caller to work out where that is! + // These members have their annotations stored elsewhere, and this flag indicates + // that is the case. It is up to the caller to work out where that is! // Once determined the caller may choose to stash the annotations in this // member... - private boolean isAnnotatedElsewhere = false; // this field is not - // serialized. + private boolean isAnnotatedElsewhere = false; private boolean isAjSynthetic = false; // generic methods have type variables @@ -106,7 +106,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno ResolvedType originalDeclaringType = joinPointSignature.getDeclaringType().resolve(inAWorld); ResolvedMemberImpl firstDefiningMember = (ResolvedMemberImpl) joinPointSignature.resolve(inAWorld); if (firstDefiningMember == null) { - return new JoinPointSignature[0]; + return JoinPointSignature.EMPTY_ARRAY; } // declaringType can be unresolved if we matched a synthetic member // generated by Aj... @@ -116,7 +116,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno ResolvedType firstDefiningType = firstDefiningMember.getDeclaringType().resolve(inAWorld); if (firstDefiningType != originalDeclaringType) { if (joinPointSignature.getKind() == Member.CONSTRUCTOR) { - return new JoinPointSignature[0]; + return JoinPointSignature.EMPTY_ARRAY; } // else if (shadowMember.isStatic()) { // return new ResolvedMember[] {firstDefiningMember}; @@ -288,10 +288,14 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno } return backingGenericMember.hasAnnotation(ofType); } - if (annotationTypes == null) { - return false; + if (annotationTypes != null) { + for (int i = 0, max = annotationTypes.length; i < max; i++) { + if (annotationTypes[i].equals(ofType)) { + return true; + } + } } - return annotationTypes.contains(ofType); + return false; } public ResolvedType[] getAnnotationTypes() { @@ -305,10 +309,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno } return backingGenericMember.getAnnotationTypes(); } - if (annotationTypes == null) { - return null; - } - return annotationTypes.toArray(new ResolvedType[] {}); + return annotationTypes; } public String getAnnotationDefaultValue() { @@ -324,20 +325,11 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno return super.getAnnotations(); } - public void setAnnotationTypes(ResolvedType[] annotationtypes) { - if (annotationTypes == null) { - annotationTypes = new HashSet(); - } - for (int i = 0; i < annotationtypes.length; i++) { - ResolvedType typeX = annotationtypes[i]; - annotationTypes.add(typeX); - } + public void setAnnotationTypes(ResolvedType[] annotationTypes) { + this.annotationTypes = annotationTypes; } public ResolvedType[][] getParameterAnnotationTypes() { - if (parameterAnnotationTypes == null) { - return null; - } return parameterAnnotationTypes; } @@ -350,12 +342,23 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno } public void addAnnotation(AnnotationAJ annotation) { - // FIXME asc only allows for annotation types, not instances - should - // it? if (annotationTypes == null) { - annotationTypes = new HashSet(); + annotationTypes = new ResolvedType[1]; + annotationTypes[0] = annotation.getType(); + annotations = new AnnotationAJ[1]; + annotations[0] = annotation; + } else { + int len = annotations.length; + AnnotationAJ[] ret = new AnnotationAJ[len + 1]; + System.arraycopy(annotations, 0, ret, 0, len); + ret[len] = annotation; + annotations = ret; + + ResolvedType[] newAnnotationTypes = new ResolvedType[len + 1]; + System.arraycopy(annotationTypes, 0, newAnnotationTypes, 0, len); + newAnnotationTypes[len] = annotation.getType(); + annotationTypes = newAnnotationTypes; } - annotationTypes.add(annotation.getType()); } public boolean isBridgeMethod() { @@ -670,14 +673,14 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno * turn into List (for example) - if (!isParameterized) then List will turn into List. */ public ResolvedMemberImpl parameterizedWith(UnresolvedType[] typeParameters, ResolvedType newDeclaringType, - boolean isParameterized, List aliases) { + boolean isParameterized, List aliases) { // PR308773 // this check had problems for the inner type of a generic type because the inner type can be represented - // by a 'simple type' if it is only sharing type variables with the outer and has none of its own. To avoid the + // by a 'simple type' if it is only sharing type variables with the outer and has none of its own. To avoid the // check going bang in this case we check for $ (crap...) - we can't check the outer because the declaring type - // is considered unresolved... + // is considered unresolved... if (// isParameterized && <-- might need this bit... - !getDeclaringType().isGenericType() && getDeclaringType().getName().indexOf("$")==-1) { + !getDeclaringType().isGenericType() && getDeclaringType().getName().indexOf("$") == -1) { throw new IllegalStateException("Can't ask to parameterize a member of non-generic type: " + getDeclaringType() + " kind(" + getDeclaringType().typeKind + ")"); } @@ -703,8 +706,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno // the same value as the type variables real name. if (aliases != null) { int posn = 0; - for (Iterator iter = aliases.iterator(); iter.hasNext();) { - String typeVariableAlias = (String) iter.next(); + for (String typeVariableAlias : aliases) { typeMap.put(typeVariableAlias, (!typeParametersSupplied ? typeVariables[posn].getFirstBound() : typeParameters[posn])); posn++; @@ -732,7 +734,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno * Replace occurrences of type variables in the signature with values contained in the map. The map is of the form * A=String,B=Integer and so a signature List Foo.m(B i) {} would become List Foo.m(Integer i) {} */ - public ResolvedMember parameterizedWith(Map m, World w) { + public ResolvedMember parameterizedWith(Map m, World w) { // if (//isParameterized && <-- might need this bit... // !getDeclaringType().isGenericType()) { // throw new IllegalStateException( @@ -802,14 +804,15 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno return typeVariables; } - protected UnresolvedType parameterize(UnresolvedType aType, Map typeVariableMap, boolean inParameterizedType, World w) { + protected UnresolvedType parameterize(UnresolvedType aType, Map typeVariableMap, + boolean inParameterizedType, World w) { if (aType instanceof TypeVariableReference) { String variableName = ((TypeVariableReference) aType).getTypeVariable().getName(); if (!typeVariableMap.containsKey(variableName)) { return aType; // if the type variable comes from the method (and // not the type) thats OK } - return (UnresolvedType) typeVariableMap.get(variableName); + return typeVariableMap.get(variableName); } else if (aType.isParameterizedType()) { if (inParameterizedType) { if (w != null) { @@ -982,7 +985,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno StringBuffer sig = new StringBuffer(); UnresolvedType[] myParameterTypes = getGenericParameterTypes(); for (int i = 0; i < myParameterTypes.length; i++) { - appendSigWithTypeVarBoundsRemoved(myParameterTypes[i], sig, new HashSet()); + appendSigWithTypeVarBoundsRemoved(myParameterTypes[i], sig, new HashSet()); } myParameterSignatureWithBoundsRemoved = sig.toString(); return myParameterSignatureWithBoundsRemoved; @@ -1019,7 +1022,8 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno // does NOT produce a meaningful java signature, but does give a unique // string suitable for // comparison. - public static void appendSigWithTypeVarBoundsRemoved(UnresolvedType aType, StringBuffer toBuffer, Set alreadyUsedTypeVars) { + public static void appendSigWithTypeVarBoundsRemoved(UnresolvedType aType, StringBuffer toBuffer, + Set alreadyUsedTypeVars) { if (aType.isTypeVariableReference()) { TypeVariableReferenceType typeVariableRT = (TypeVariableReferenceType) aType; // pr204505 diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java index 7e4932f96..0f898eec4 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java @@ -1012,6 +1012,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl // ---- fields public static final ResolvedType[] NONE = new ResolvedType[0]; + public static final ResolvedType[] EMPTY_ARRAY = NONE; public static final Primitive BYTE = new Primitive("B", 1, 0); public static final Primitive CHAR = new Primitive("C", 1, 1); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java b/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java index f982f89c3..28c8aacf6 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedResolvedMemberImpl.java @@ -12,7 +12,7 @@ package org.aspectj.weaver.reflect; import java.lang.reflect.Member; -import java.util.Iterator; +import java.util.Set; import org.aspectj.weaver.AnnotationAJ; import org.aspectj.weaver.MemberKind; @@ -22,8 +22,7 @@ import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.UnresolvedType; /** - * Subtype of ResolvedMemberImpl used in reflection world. Knows how to get - * annotations from a java.lang.reflect.Member + * Subtype of ResolvedMemberImpl used in reflection world. Knows how to get annotations from a java.lang.reflect.Member * */ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { @@ -41,10 +40,8 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { * @param name * @param parameterTypes */ - public ReflectionBasedResolvedMemberImpl(MemberKind kind, - UnresolvedType declaringType, int modifiers, - UnresolvedType returnType, String name, - UnresolvedType[] parameterTypes, Member reflectMember) { + public ReflectionBasedResolvedMemberImpl(MemberKind kind, UnresolvedType declaringType, int modifiers, + UnresolvedType returnType, String name, UnresolvedType[] parameterTypes, Member reflectMember) { super(kind, declaringType, modifiers, returnType, name, parameterTypes); this.reflectMember = reflectMember; } @@ -58,13 +55,10 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { * @param parameterTypes * @param checkedExceptions */ - public ReflectionBasedResolvedMemberImpl(MemberKind kind, - UnresolvedType declaringType, int modifiers, - UnresolvedType returnType, String name, - UnresolvedType[] parameterTypes, - UnresolvedType[] checkedExceptions, Member reflectMember) { - super(kind, declaringType, modifiers, returnType, name, parameterTypes, - checkedExceptions); + public ReflectionBasedResolvedMemberImpl(MemberKind kind, UnresolvedType declaringType, int modifiers, + UnresolvedType returnType, String name, UnresolvedType[] parameterTypes, UnresolvedType[] checkedExceptions, + Member reflectMember) { + super(kind, declaringType, modifiers, returnType, name, parameterTypes, checkedExceptions); this.reflectMember = reflectMember; } @@ -78,14 +72,10 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { * @param checkedExceptions * @param backingGenericMember */ - public ReflectionBasedResolvedMemberImpl(MemberKind kind, - UnresolvedType declaringType, int modifiers, - UnresolvedType returnType, String name, - UnresolvedType[] parameterTypes, - UnresolvedType[] checkedExceptions, + public ReflectionBasedResolvedMemberImpl(MemberKind kind, UnresolvedType declaringType, int modifiers, + UnresolvedType returnType, String name, UnresolvedType[] parameterTypes, UnresolvedType[] checkedExceptions, ResolvedMember backingGenericMember, Member reflectMember) { - super(kind, declaringType, modifiers, returnType, name, parameterTypes, - checkedExceptions, backingGenericMember); + super(kind, declaringType, modifiers, returnType, name, parameterTypes, checkedExceptions, backingGenericMember); this.reflectMember = reflectMember; } @@ -96,8 +86,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { * @param name * @param signature */ - public ReflectionBasedResolvedMemberImpl(MemberKind kind, - UnresolvedType declaringType, int modifiers, String name, + public ReflectionBasedResolvedMemberImpl(MemberKind kind, UnresolvedType declaringType, int modifiers, String name, String signature, Member reflectMember) { super(kind, declaringType, modifiers, name, signature); this.reflectMember = reflectMember; @@ -109,8 +98,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { // generic signature support - public void setGenericSignatureInformationProvider( - GenericSignatureInformationProvider gsigProvider) { + public void setGenericSignatureInformationProvider(GenericSignatureInformationProvider gsigProvider) { this.gsigInfoProvider = gsigProvider; } @@ -119,6 +107,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { * * @see org.aspectj.weaver.ResolvedMemberImpl#getGenericParameterTypes() */ + @Override public UnresolvedType[] getGenericParameterTypes() { return this.gsigInfoProvider.getGenericParameterTypes(this); } @@ -128,6 +117,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { * * @see org.aspectj.weaver.ResolvedMemberImpl#getGenericReturnType() */ + @Override public UnresolvedType getGenericReturnType() { return this.gsigInfoProvider.getGenericReturnType(this); } @@ -137,6 +127,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { * * @see org.aspectj.weaver.ResolvedMemberImpl#isSynthetic() */ + @Override public boolean isSynthetic() { return this.gsigInfoProvider.isSynthetic(this); } @@ -146,6 +137,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { * * @see org.aspectj.weaver.ResolvedMemberImpl#isVarargsMethod() */ + @Override public boolean isVarargsMethod() { return this.gsigInfoProvider.isVarArgs(this); } @@ -155,6 +147,7 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { * * @see org.aspectj.weaver.ResolvedMemberImpl#isBridgeMethod() */ + @Override public boolean isBridgeMethod() { return this.gsigInfoProvider.isBridge(this); } @@ -165,52 +158,66 @@ public class ReflectionBasedResolvedMemberImpl extends ResolvedMemberImpl { this.annotationFinder = finder; } + @Override public boolean hasAnnotation(UnresolvedType ofType) { unpackAnnotations(); return super.hasAnnotation(ofType); } + @Override public boolean hasAnnotations() { unpackAnnotations(); return super.hasAnnotations(); } + @Override public ResolvedType[] getAnnotationTypes() { unpackAnnotations(); return super.getAnnotationTypes(); } + @Override public AnnotationAJ getAnnotationOfType(UnresolvedType ofType) { unpackAnnotations(); - if (annotationFinder == null) + if (annotationFinder == null || annotationTypes == null) { return null; - for (Iterator iterator = annotationTypes.iterator(); iterator.hasNext();) { - ResolvedType type = (ResolvedType) iterator.next(); + } + for (ResolvedType type : annotationTypes) { if (type.getSignature().equals(ofType.getSignature())) { - return annotationFinder.getAnnotationOfType(ofType, - reflectMember); + return annotationFinder.getAnnotationOfType(ofType, reflectMember); } } return null; } + @Override public String getAnnotationDefaultValue() { - if (annotationFinder == null) + if (annotationFinder == null) { return null; + } return annotationFinder.getAnnotationDefaultValue(reflectMember); } + @Override public ResolvedType[][] getParameterAnnotationTypes() { if (parameterAnnotationTypes == null && annotationFinder != null) { - parameterAnnotationTypes = annotationFinder - .getParameterAnnotationTypes(reflectMember); + parameterAnnotationTypes = annotationFinder.getParameterAnnotationTypes(reflectMember); } return parameterAnnotationTypes; } private void unpackAnnotations() { if (annotationTypes == null && annotationFinder != null) { - annotationTypes = annotationFinder.getAnnotations(reflectMember); + Set s = annotationFinder.getAnnotations(reflectMember); + if (s.size() == 0) { + annotationTypes = ResolvedType.EMPTY_ARRAY; + } else { + annotationTypes = new ResolvedType[s.size()]; + int i = 0; + for (Object o : s) { + annotationTypes[i++] = (ResolvedType) o; + } + } } } } -- 2.39.5