From 065692237c0c3a129e6555569e857aebbe5b1167 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Mon, 24 Mar 2025 13:55:06 +0100 Subject: [PATCH] =?UTF-8?q?Document=20that=20@=E2=81=A0AliasFor(attribute)?= =?UTF-8?q?=20is=20optional=20in=20override=20use=20cases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit documents that `attribute` is optional in @⁠AliasFor for meta-annotation attribute overrides with the same name. Closes gh-34641 --- .../java/org/springframework/core/annotation/AliasFor.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AliasFor.java b/spring-core/src/main/java/org/springframework/core/annotation/AliasFor.java index 2a875b0476..88c52ebf01 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AliasFor.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AliasFor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,8 @@ import java.lang.annotation.Target; *
    *
  1. The attribute that is an alias for an attribute in a meta-annotation * must be annotated with {@code @AliasFor}, and {@link #attribute} must - * reference the attribute in the meta-annotation.
  2. + * reference the attribute in the meta-annotation (unless both attributes have + * the same name). *
  3. Aliased attributes must declare the same return type.
  4. *
  5. {@link #annotation} must reference the meta-annotation.
  6. *
  7. The referenced meta-annotation must be meta-present on the @@ -191,6 +192,8 @@ public @interface AliasFor { /** * The name of the attribute that this attribute is an alias for. + *

    May be omitted if this attribute is an alias for an attribute in a + * meta-annotation and both attributes have the same name. * @see #value */ @AliasFor("value")