]> source.dussan.org Git - aspectj.git/commitdiff
bring refactoring up to date.
authoraclement <aclement>
Mon, 12 May 2008 19:29:19 +0000 (19:29 +0000)
committeraclement <aclement>
Mon, 12 May 2008 19:29:19 +0000 (19:29 +0000)
weaver/src/org/aspectj/weaver/TypeVariable.java
weaver/src/org/aspectj/weaver/bcel/BcelField.java
weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java

index d85d7412daa384966d91cbc9232be9b0495a3ad5..d5045ecd84e2748c7de33bea15ce8d03fc10a86d 100644 (file)
@@ -215,7 +215,20 @@ public class TypeVariable {
        // 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
@@ -379,6 +392,7 @@ public class TypeVariable {
 
        public String getGenericSignature() {
                return "T"+name+";";
+//             return "T"+getSignature();
        }
        public String getErasureSignature() {
                return getFirstBound().getErasureSignature();
index 5b374d683809e7e244b1a7ba445943fd910e866c..34204c55bb58cd929bad1f98adac52e74e476d8b 100644 (file)
@@ -145,6 +145,14 @@ final class BcelField extends ResolvedMemberImpl {
                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();
index c00c4a73f00dc5c71a288db1a6a6a012cdc52829..1def36ad7bb633f16634372aa2a42636d8d7b2d3 100644 (file)
@@ -380,14 +380,15 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern {
        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() {
index 0bbfa1e079f10cddfb9dbc1785d33ce7b67e0089..362c1b045c30a26c74eb494c989ce21a3357a938 100644 (file)
@@ -344,14 +344,16 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
        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)