private ResolvedMember firstDefiningMember;
ResolvedType firstDefiningType;
private World world;
- private List discoveredSignatures = new ArrayList();
+ private List<JoinPointSignature> discoveredSignatures = new ArrayList<JoinPointSignature>();
private List<JoinPointSignature> additionalSignatures = Collections.emptyList();
private Iterator<JoinPointSignature> discoveredSignaturesIterator = null;
private Iterator<ResolvedType> superTypeIterator = null;
private boolean isProxy = false;
- private Set visitedSuperTypes = new HashSet();
- private List /* SearchPair */yetToBeProcessedSuperMembers = null;
+ private Set<ResolvedType> visitedSuperTypes = new HashSet<ResolvedType>();
+ private List<SearchPair> yetToBeProcessedSuperMembers = null;
private boolean iteratingOverDiscoveredSignatures = true;
private boolean couldBeFurtherAsYetUndiscoveredSignatures = true;
private final static UnresolvedType jlrProxy = UnresolvedType.forSignature("Ljava/lang/reflect/Proxy;");
- public JoinPointSignatureIterator(Member joinPointSignature, World inAWorld) {
+ public JoinPointSignatureIterator(Member joinPointSignature, World world) {
this.signaturesOfMember = joinPointSignature;
- this.world = inAWorld;
+ this.world = world;
addSignaturesUpToFirstDefiningMember();
if (!shouldWalkUpHierarchy()) {
couldBeFurtherAsYetUndiscoveredSignatures = false;
}
}
- List declaringTypes = new ArrayList();
- accumulateTypesInBetween(originalDeclaringType, firstDefiningType, declaringTypes);
- for (Iterator iter = declaringTypes.iterator(); iter.hasNext();) {
- ResolvedType declaringType = (ResolvedType) iter.next();
- ResolvedMember member = ((ResolvedMemberImpl) firstDefiningMember).withSubstituteDeclaringType(declaringType);
- discoveredSignatures.add(member);
+ if (originalDeclaringType == firstDefiningType) {
+ // a common case
+ discoveredSignatures.add(new JoinPointSignature(firstDefiningMember, originalDeclaringType));
+ } else {
+ List<ResolvedType> declaringTypes = new ArrayList<ResolvedType>();
+ accumulateTypesInBetween(originalDeclaringType, firstDefiningType, declaringTypes);
+ for (ResolvedType declaringType : declaringTypes) {
+ discoveredSignatures.add(new JoinPointSignature(firstDefiningMember, declaringType));
+ }
}
}
}
}
if (yetToBeProcessedSuperMembers != null && !yetToBeProcessedSuperMembers.isEmpty()) {
- SearchPair nextUp = (SearchPair) yetToBeProcessedSuperMembers.remove(0);
+ SearchPair nextUp = yetToBeProcessedSuperMembers.remove(0);
firstDefiningType = nextUp.type;
firstDefiningMember = nextUp.member;
superTypeIterator = null;
@Override
public String getSignatureForAttribute() {
- if (genericType == null || typeParameters == null)
+ if (genericType == null || typeParameters == null) {
return getSignature();
+ }
return makeDeclaredSignature(genericType, typeParameters);
}
}
if (this.isRawType() && other.isParameterizedType()) {
- return this.getGenericType().isCoerceableFrom(((ReferenceType) other.getRawType()));
+ return this.getGenericType().isCoerceableFrom((other.getRawType()));
}
if (!this.isInterface() && !other.isInterface()) {
// always safe
for (int ai = 0, alen = a.length; ai < alen; ai++) {
for (int bi = 0, blen = b.length; bi < blen; bi++) {
- if (!b[bi].isCompatibleWith(a[ai]))
+ if (!b[bi].isCompatibleWith(a[ai])) {
return false;
+ }
}
}
return true;
}
private final boolean isCoerceableFromParameterizedType(ResolvedType other) {
- if (!other.isParameterizedType())
+ if (!other.isParameterizedType()) {
return false;
- ResolvedType myRawType = (ResolvedType) getRawType();
- ResolvedType theirRawType = (ResolvedType) other.getRawType();
+ }
+ ResolvedType myRawType = getRawType();
+ ResolvedType theirRawType = other.getRawType();
if (myRawType == theirRawType || myRawType.isCoerceableFrom(theirRawType)) {
if (getTypeParameters().length == other.getTypeParameters().length) {
// there's a chance it can be done
// coerceable from e.g. List<T>
if (myTypeParameters[i].isGenericWildcard()) {
BoundedReferenceType wildcard = (BoundedReferenceType) myTypeParameters[i];
- if (!wildcard.canBeCoercedTo(theirTypeParameters[i]))
+ if (!wildcard.canBeCoercedTo(theirTypeParameters[i])) {
return false;
+ }
} else if (myTypeParameters[i].isTypeVariableReference()) {
TypeVariableReferenceType tvrt = (TypeVariableReferenceType) myTypeParameters[i];
TypeVariable tv = tvrt.getTypeVariable();
tv.resolve(world);
- if (!tv.canBeBoundTo(theirTypeParameters[i]))
+ if (!tv.canBeBoundTo(theirTypeParameters[i])) {
return false;
+ }
} else if (theirTypeParameters[i].isTypeVariableReference()) {
TypeVariableReferenceType tvrt = (TypeVariableReferenceType) theirTypeParameters[i];
TypeVariable tv = tvrt.getTypeVariable();
tv.resolve(world);
- if (!tv.canBeBoundTo(myTypeParameters[i]))
+ if (!tv.canBeBoundTo(myTypeParameters[i])) {
return false;
+ }
} else if (theirTypeParameters[i].isGenericWildcard()) {
BoundedReferenceType wildcard = (BoundedReferenceType) theirTypeParameters[i];
if (!wildcard.canBeCoercedTo(myTypeParameters[i])) {
@Override
public boolean isAssignableFrom(ResolvedType other, boolean allowMissing) {
if (other.isPrimitiveType()) {
- if (!world.isInJava5Mode())
+ if (!world.isInJava5Mode()) {
return false;
- if (ResolvedType.validBoxing.contains(this.getSignature() + other.getSignature()))
+ }
+ if (ResolvedType.validBoxing.contains(this.getSignature() + other.getSignature())) {
return true;
+ }
}
if (this == other) {
return true;
}
if ((this.isRawType() || this.isGenericType()) && other.isParameterizedType()) {
- if (isAssignableFrom((ResolvedType) other.getRawType())) {
+ if (isAssignableFrom(other.getRawType())) {
return true;
}
}
if (this.isRawType() && other.isGenericType()) {
- if (isAssignableFrom((ResolvedType) other.getRawType()))
+ if (isAssignableFrom(other.getRawType())) {
return true;
+ }
}
if (this.isGenericType() && other.isRawType()) {
- if (isAssignableFrom(other.getGenericType()))
+ if (isAssignableFrom(other.getGenericType())) {
return true;
+ }
}
// if (this.isParameterizedType() && other.isRawType()) {
// if (((ReferenceType) this.getRawType()).isAssignableFrom(other.getGenericType())) {
}
}
}
- if (wildcardsAllTheWay && !other.isParameterizedType())
+ if (wildcardsAllTheWay && !other.isParameterizedType()) {
return true;
+ }
// we have to match by parameters one at a time
ResolvedType[] theirParameters = other.getResolvedTypeParameters();
boolean parametersAssignable = true;
} else {
parametersAssignable = false;
}
- if (parametersAssignable)
+ if (parametersAssignable) {
return true;
+ }
}
}
}
}
- if (allowMissing && other.isMissing())
+ if (allowMissing && other.isMissing()) {
return false;
+ }
for (Iterator i = other.getDirectSupertypes(); i.hasNext();) {
- if (this.isAssignableFrom((ResolvedType) i.next(), allowMissing))
+ if (this.isAssignableFrom((ResolvedType) i.next(), allowMissing)) {
return true;
+ }
}
return false;
}
@Override
public ResolvedMember[] getDeclaredFields() {
- if (parameterizedFields != null)
+ if (parameterizedFields != null) {
return parameterizedFields;
+ }
if (isParameterizedType() || isRawType()) {
ResolvedMember[] delegateFields = delegate.getDeclaredFields();
parameterizedFields = new ResolvedMember[delegateFields.length];
*/
@Override
public ResolvedType[] getDeclaredInterfaces() {
- if (parameterizedInterfaces != null)
+ if (parameterizedInterfaces != null) {
return parameterizedInterfaces;
+ }
ResolvedType[] delegateInterfaces = delegate.getDeclaredInterfaces();
if (newInterfaces != null) {
ResolvedType[] extraInterfaces = new ResolvedType[delegateInterfaces.length + newInterfaces.length];
TypeVariable[] thisTypesTVars = getGenericType().getTypeVariables();
for (int i = 0; i < thisTypesTVars.length; i++) {
TypeVariable tv = thisTypesTVars[i];
- if (tv.getName().equals(tvname))
+ if (tv.getName().equals(tvname)) {
return i;
+ }
}
return -1;
}
@Override
public ResolvedMember[] getDeclaredMethods() {
- if (parameterizedMethods != null)
+ if (parameterizedMethods != null) {
return parameterizedMethods;
+ }
if (isParameterizedType() || isRawType()) {
ResolvedMember[] delegateMethods = delegate.getDeclaredMethods();
UnresolvedType[] parameters = getTypesForMemberParameterization();
@Override
public ResolvedMember[] getDeclaredPointcuts() {
- if (parameterizedPointcuts != null)
+ if (parameterizedPointcuts != null) {
return parameterizedPointcuts;
+ }
if (isParameterizedType()) {
ResolvedMember[] delegatePointcuts = delegate.getDeclaredPointcuts();
parameterizedPointcuts = new ResolvedMember[delegatePointcuts.length];
return parameters;
}
- @Override
- public UnresolvedType getRawType() {
- return super.getRawType().resolve(world);
- }
-
@Override
public TypeVariable[] getTypeVariables() {
if (this.typeVariables == null) {
@Override
public Collection<Declare> getDeclares() {
- if (parameterizedDeclares != null)
+ if (parameterizedDeclares != null) {
return parameterizedDeclares;
+ }
Collection<Declare> declares = null;
if (ajMembersNeedParameterization()) {
Collection genericDeclares = delegate.getDeclares();
// Don't copy from BcelObjectType to EclipseSourceType - the context may
// be tidied (result null'd) after previous weaving
if (this.delegate != null && this.delegate.copySourceContext()
- && this.delegate.getSourceContext() != SourceContextImpl.UNKNOWN_SOURCE_CONTEXT)
+ && this.delegate.getSourceContext() != SourceContextImpl.UNKNOWN_SOURCE_CONTEXT) {
((AbstractReferenceTypeDelegate) delegate).setSourceContext(this.delegate.getSourceContext());
+ }
this.delegate = delegate;
for (Iterator it = this.derivativeTypes.iterator(); it.hasNext();) {
ReferenceType dependent = (ReferenceType) it.next();
@Override
public ResolvedType getGenericType() {
- if (isGenericType())
+ if (isGenericType()) {
return this;
+ }
return genericType;
}