From 6245de00a391246d71733a3fac138c1f8e70badf Mon Sep 17 00:00:00 2001 From: Looly Date: Mon, 24 Mar 2025 12:29:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96`CombinationAnnotationElement?= =?UTF-8?q?`=E6=B3=A8=E8=A7=A3=E6=95=B0=E7=BB=84=E6=80=A7=E8=83=BD?= =?UTF-8?q?=EF=BC=88pr#1323@Gitee=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../annotation/elements/CombinationAnnotatedElement.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/annotation/elements/CombinationAnnotatedElement.java b/hutool-core/src/main/java/org/dromara/hutool/core/annotation/elements/CombinationAnnotatedElement.java index 56d7ad9ef..46a7c9201 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/annotation/elements/CombinationAnnotatedElement.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/annotation/elements/CombinationAnnotatedElement.java @@ -24,7 +24,6 @@ import org.dromara.hutool.core.map.TableMap; import java.io.Serializable; import java.lang.annotation.*; import java.lang.reflect.AnnotatedElement; -import java.util.Arrays; import java.util.Collection; import java.util.Map; import java.util.Set; @@ -135,7 +134,10 @@ public class CombinationAnnotatedElement implements AnnotatedElement, Serializab parseDeclared(declaredAnnotations); final Annotation[] annotations = element.getAnnotations(); - if (Arrays.equals(declaredAnnotations, annotations)) { +// if (Arrays.equals(declaredAnnotations, annotations)) { + // pr#1323 如果子类重写了父类的注解,虽然两者数组内部元素一样的,但是数组中的顺序可能不一样 + // getAnnotations()的包含父类,getDeclaredAnnotations()不包含父类。他们两是一个包含关系,只会存在后者的注解元素大于等于前者的情况。 + if (declaredAnnotations.length == annotations.length) { this.annotationMap = this.declaredAnnotationMap; } else { this.annotationMap = new TableMap<>();