// can match any type in the range of the type variable...
// XXX what about interfaces?
private boolean matchingBounds(TypeVariableReferenceType tvrt) {
- if (tvrt.getUpperBound() != getUpperBound()) return false;
+ if (tvrt.getUpperBound() != getUpperBound()) {
+ UnresolvedType unresolvedCandidateUpperBound = tvrt.getUpperBound();
+ UnresolvedType unresolvedThisUpperBound = getUpperBound();
+ if (unresolvedCandidateUpperBound instanceof ResolvedType && unresolvedThisUpperBound instanceof ResolvedType) {
+ ResolvedType candidateUpperBound = (ResolvedType)unresolvedCandidateUpperBound;
+ ResolvedType thisUpperBound = (ResolvedType)unresolvedThisUpperBound;
+ if (!thisUpperBound.isAssignableFrom(candidateUpperBound)) {
+ return false;
+ }
+ } else {
+ // not right, they shouldnt have been unresolved...
+ return false;
+ }
+ }
if (tvrt.hasLowerBound() != (getLowerBound() != null)) return false;
if (tvrt.hasLowerBound() && tvrt.getLowerBound() != getLowerBound()) return false;
// either we both have bounds, or neither of us have bounds
public String getGenericSignature() {
return "T"+name+";";
+// return "T"+getSignature();
}
public String getErasureSignature() {
return getFirstBound().getErasureSignature();
return annotations;
}
+ public AnnotationX getAnnotationOfType(UnresolvedType ofType) {
+ ensureAnnotationTypesRetrieved();
+ for (int i=0; i<annotations.length; i++) {
+ if (annotations[i].getTypeName().equals(ofType.getName())) return annotations[i];
+ }
+ return null;
+ }
+
private void ensureAnnotationTypesRetrieved() {
if (annotationTypes == null) {
AnnotationGen annos[] = field.getAnnotations();
public boolean equals(Object obj) {
if (!(obj instanceof ExactAnnotationTypePattern)) return false;
ExactAnnotationTypePattern other = (ExactAnnotationTypePattern) obj;
- return (other.annotationType.equals(annotationType)) && isForParameterAnnotationMatch()==other.isForParameterAnnotationMatch();
+ return (other.annotationType.equals(annotationType)) && isForParameterAnnotationMatch()==other.isForParameterAnnotationMatch() &&
+ (annotationValues==null?other.annotationValues==null:annotationValues.equals(other.annotationValues));
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
- return annotationType.hashCode()*37+(isForParameterAnnotationMatch()?0:1);
+ return (((annotationType.hashCode())*37+(isForParameterAnnotationMatch()?0:1))*37)+(annotationValues==null?0:annotationValues.hashCode());
}
public String toString() {
public boolean equals(Object obj) {
if (!(obj instanceof WildAnnotationTypePattern)) return false;
WildAnnotationTypePattern other = (WildAnnotationTypePattern) obj;
- return other.typePattern.equals(typePattern) && this.isForParameterAnnotationMatch()==other.isForParameterAnnotationMatch();
+ return other.typePattern.equals(typePattern) &&
+ this.isForParameterAnnotationMatch()==other.isForParameterAnnotationMatch() &&
+ (annotationValues==null?other.annotationValues==null:annotationValues.equals(other.annotationValues));
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
- return (17 + 37*typePattern.hashCode())*37+(isForParameterAnnotationMatch()?0:1);
+ return (((17 + 37*typePattern.hashCode())*37+(isForParameterAnnotationMatch()?0:1))*37)+(annotationValues==null?0:annotationValues.hashCode());
}
/* (non-Javadoc)