aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.matcher
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2023-01-15 01:16:24 +0100
committerAlexander Kriegisch <Alexander@Kriegisch.name>2023-01-15 14:41:51 +0100
commitc9afd2ee1b1a701bffbe1d79f2a186b96c7e4f45 (patch)
treeced1bea74802933b361f02c01ea98ebedc071048 /org.aspectj.matcher
parent9cf956c2838cbb4f5fd3ad46064e579df3752456 (diff)
downloadaspectj-c9afd2ee1b1a701bffbe1d79f2a186b96c7e4f45.tar.gz
aspectj-c9afd2ee1b1a701bffbe1d79f2a186b96c7e4f45.zip
WildTypePattern: fix hashCode and toString methods
Especially 'hashCode' did not correspond to 'equals', disregarding several fields, array dimension information being only one of them. This led to parts of pointcuts being ignored, because they were regarded as duplicates. Example: execution(Foo* *(..)) && !execution(Foo*[] *(..)) Here, the negated pattern was falsely regarded as equal to the first pattern, leading to an "A && !A" situation, i.e. no match at all. Furthermore, 'toString' did not print array strings, i.e. instead of "Foo*[][]" something like "Foo*" was printed. This false information was also present in annotations generated by the weaver. FuzzilyMatchingAspect was adjusted to actually match exactly once, as expected, for the "Foo*" return types, i.e. exclusions for the array return types have been added. Relates to #24. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'org.aspectj.matcher')
-rw-r--r--org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java
index e43b6ca94..212378bf7 100644
--- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java
+++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java
@@ -1172,7 +1172,7 @@ public class WildTypePattern extends TypePattern {
StringBuilder buf = new StringBuilder();
if (annotationPattern != AnnotationTypePattern.ANY) {
buf.append('(');
- buf.append(annotationPattern.toString());
+ buf.append(annotationPattern);
buf.append(' ');
}
for (int i = 0, len = namePatterns.length; i < len; i++) {
@@ -1183,16 +1183,16 @@ public class WildTypePattern extends TypePattern {
if (i > 0) {
buf.append(".");
}
- buf.append(name.toString());
+ buf.append(name);
}
}
if (upperBound != null) {
buf.append(" extends ");
- buf.append(upperBound.toString());
+ buf.append(upperBound);
}
if (lowerBound != null) {
buf.append(" super ");
- buf.append(lowerBound.toString());
+ buf.append(lowerBound);
}
if (typeParameters != null && typeParameters.size() != 0) {
buf.append("<");
@@ -1202,6 +1202,9 @@ public class WildTypePattern extends TypePattern {
if (includeSubtypes) {
buf.append('+');
}
+ for (int i = 0; i < getDimensions(); i++) {
+ buf.append("[]");
+ }
if (isVarArgs) {
buf.append("...");
}
@@ -1271,7 +1274,11 @@ public class WildTypePattern extends TypePattern {
for (NamePattern namePattern : namePatterns) {
result = 37 * result + namePattern.hashCode();
}
+ result = 37 * result + (includeSubtypes ? 1 : 0);
+ result = 37 * result + dim;
+ result = 37 * result + (isVarArgs ? 1 : 0);
result = 37 * result + annotationPattern.hashCode();
+ result = 37 * result + typeParameters.hashCode();
if (upperBound != null) {
result = 37 * result + upperBound.hashCode();
}