Skip to content

AnnotationBeanNameGenerator issues warning about explicitly aliased value attribute #34317

Closed
@odrotbohm

Description

@odrotbohm

Assume an annotation that declares a value() attribute explicitly aliasing an attribute other than @Component(value = "…").

@interface MyAnnotation {

  @AliasFor(annotation = Foo.class, attribute = "…")
  String value() default "";
}

If that annotation gets used with a set value (@MyAnnotation("foo")), I now see a warning:

Support for convention-based stereotype names is deprecated and will \
be removed in a future version of the framework. Please annotate the \
'value' attribute in @MyAnnotation with @AliasFor(annotation=Component.class) \
to declare an explicit alias for @Component's 'value' attribute.

This warning should not be issued if the value() attribute is explicitly aliased to some attribute other than @Component's value.

Also, the phrasing of "convention-based stereotype names" in combination with @Component led me to believe it's about the bean name stereotypically being derived from the class name (which made it particularly puzzling as the warning only appears with a value set, which would not trigger that convention). It turns out this term is actually referring to the default aliasing convention of the annotation attributes (the @MyAnnotation.value() conventionally being considered a redeclaration of @Component.value()). I wonder if the message's wording could be adapted to clarify this.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions