aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2023-01-17 15:46:18 +0100
committerAlexander Kriegisch <Alexander@Kriegisch.name>2024-04-12 15:32:39 +0200
commit2a1ec081e1958afa47a884cad4766e6ca88571aa (patch)
tree7a3694385e1fe862c7276e032130bcafc6a76a0c
parent397796d67610961245eea74f4aba5f479bf1ebd5 (diff)
downloadaspectj-2a1ec081e1958afa47a884cad4766e6ca88571aa.tar.gz
aspectj-2a1ec081e1958afa47a884cad4766e6ca88571aa.zip
WildTypePattern: match generic type params correctly for array types
For array reference types, match type parameters on component type, not on array type itself. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
-rw-r--r--org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildTypePattern.java9
1 files changed, 8 insertions, 1 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 a77421e56..4a30f2281 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
@@ -14,6 +14,7 @@ package org.aspectj.weaver.patterns;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@@ -25,6 +26,7 @@ import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FileUtil;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.AjAttribute;
+import org.aspectj.weaver.ArrayReferenceType;
import org.aspectj.weaver.BCException;
import org.aspectj.weaver.BoundedReferenceType;
import org.aspectj.weaver.CompressingDataOutputStream;
@@ -39,6 +41,7 @@ import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.UnresolvedTypeVariableReferenceType;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.WeaverMessages;
+import org.aspectj.weaver.WildcardedUnresolvedType;
import org.aspectj.weaver.World;
/**
@@ -233,7 +236,8 @@ public class WildTypePattern extends TypePattern {
// Ensure the annotation pattern is resolved
annotationPattern.resolve(type.getWorld());
- return matchesExactlyByName(targetTypeName.replaceFirst("(\\[\\])+$", ""), type.isAnonymous(), type.isNested()) && matchesParameters(type, STATIC)
+ return matchesExactlyByName(targetTypeName.replaceFirst("(\\[\\])+$", ""), type.isAnonymous(), type.isNested())
+ && matchesParameters(type, STATIC)
&& matchesArray(type)
&& matchesBounds(type, STATIC)
&& annotationPattern.matches(annotatedType, type.temporaryAnnotationTypes).alwaysTrue();
@@ -242,6 +246,9 @@ public class WildTypePattern extends TypePattern {
// we've matched against the base (or raw) type, but if this type pattern specifies parameters or
// type variables we need to make sure we match against them too
private boolean matchesParameters(ResolvedType aType, MatchKind staticOrDynamic) {
+ // For array reference types, match type parameters on component type, not on array type itself
+ if (aType instanceof ArrayReferenceType)
+ aType = aType.getResolvedComponentType();
if (!isGeneric && typeParameters.size() > 0) {
if (!aType.isParameterizedType()) {
return false;