aboutsummaryrefslogtreecommitdiffstats
path: root/tests
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 /tests
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 'tests')
-rw-r--r--tests/bugs1919/github_24/FuzzilyMatchingAspect.aj26
1 files changed, 20 insertions, 6 deletions
diff --git a/tests/bugs1919/github_24/FuzzilyMatchingAspect.aj b/tests/bugs1919/github_24/FuzzilyMatchingAspect.aj
index d7c32a70a..b40c13c62 100644
--- a/tests/bugs1919/github_24/FuzzilyMatchingAspect.aj
+++ b/tests/bugs1919/github_24/FuzzilyMatchingAspect.aj
@@ -1,25 +1,39 @@
public aspect FuzzilyMatchingAspect {
- after() : execution(public MaybeMissing* MaybeMissing*.*()) {
+
+ pointcut returnRefTypeSimpleOrArray() : execution(public MaybeMissing* MaybeMissing*.*());
+ pointcut return1DimRefTypeArray() : execution(public MaybeMissing*[] MaybeMissing*.*());
+ pointcut return2DimRefTypeArray() : execution(public MaybeMissing*[][] MaybeMissing*.*());
+
+ // Return type 'MaybeMissing*' also matches array types due to the '*' at the end.
+ // Therefore, explicitly exclude array pointcuts in order to only match the method returning the simple type.
+ after() : returnRefTypeSimpleOrArray() && !return1DimRefTypeArray() && !return2DimRefTypeArray() {
System.out.println(thisJoinPoint);
}
- after() : execution(public MaybeMissing*[] MaybeMissing*.*()) {
+ after() : return1DimRefTypeArray() {
System.out.println(thisJoinPoint);
}
- after() : execution(public MaybeMissing*[][] MaybeMissing*.*()) {
+ after() : return2DimRefTypeArray() {
System.out.println(thisJoinPoint);
}
- after() : execution(public in* MaybeMissing*.*()) {
+ pointcut returnPrimitiveTypeSimpleOrArray() : execution(public in* MaybeMissing*.*());
+ pointcut return1DimPrimitiveTypeArray() : execution(public in*[] MaybeMissing*.*());
+ pointcut return2DimPrimitiveTypeArray() : execution(public in*[][] MaybeMissing*.*());
+
+ // Return type 'in*' also matches array types due to the '*' at the end.
+ // Therefore, explicitly exclude array pointcuts in order to only match the method returning the simple type.
+ after() : returnPrimitiveTypeSimpleOrArray() && !return1DimPrimitiveTypeArray() && !return2DimPrimitiveTypeArray() {
System.out.println(thisJoinPoint);
}
- after() : execution(public in*[] MaybeMissing*.*()) {
+ after() : return1DimPrimitiveTypeArray() {
System.out.println(thisJoinPoint);
}
- after() : execution(public in*[][] MaybeMissing*.*()) {
+ after() : return2DimPrimitiveTypeArray() {
System.out.println(thisJoinPoint);
}
+
}