aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2008-05-10 04:25:31 +0000
committeraclement <aclement>2008-05-10 04:25:31 +0000
commitf365ababc310ac7edd90c7ebcbf91690d7ec2ed0 (patch)
tree03bb898c257dd0c91d4de4e94acfed72f046eea7
parentb6464f5bb94272e01fd77fab1c3a508334eefa8a (diff)
downloadaspectj-f365ababc310ac7edd90c7ebcbf91690d7ec2ed0.tar.gz
aspectj-f365ababc310ac7edd90c7ebcbf91690d7ec2ed0.zip
227993: annotation value matching support for field annotations. plus hashcode/equals on annotationtypepatterns where it was missing!
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelField.java10
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java5
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java6
3 files changed, 16 insertions, 5 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelField.java b/weaver/src/org/aspectj/weaver/bcel/BcelField.java
index b2a7e6b0d..c54b92869 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelField.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelField.java
@@ -119,7 +119,15 @@ final class BcelField extends ResolvedMemberImpl {
ensureAnnotationTypesRetrieved();
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) {
Annotation annos[] = field.getAnnotations();
diff --git a/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
index 0dafaedd7..393532872 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
@@ -379,14 +379,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() {
diff --git a/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
index 0bbfa1e07..362c1b045 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
@@ -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)