Skip to content

AnnotationFormatterFactory should support @AliasFor [SPR-14844] #19410

Closed

Description

@spring-projects-issues

Sebastian Davids opened SPR-14844 and commented

Pseudo code:

public @interface MyAnnotation {
   @AliasFor("alias")
   String value() default "";

   @AliasFor("value")
   String alias() default "not aliased";
}
public class Bean {
   @MyAnnotation("aliased")
   private String toBeAliased;
//...
}
public class MyAnnotationFormatterFactory implements AnnotationFormatterFactory<MyAnnotation> {

  public Printer<?> getPrinter(MyAnnotation annotation, Class<?> fieldType) {
      String alias = annotation.alias();
//...
}

Expectation would be alias to be "aliased" and not "not aliased".


Affects: 4.3.3

Issue Links:

Referenced from: commits 62918ca, bf9083d

Activity

  1. spring-projects-issues commented on Oct 28, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Thanks for raising this! Indeed: an unfortunate limitation, originating from the legacy annotation support in TypeDescriptor. I've revised this towards our modern-day 4.3 facilities now, with formatting annotations now being equally capable (and following the same rules) as the general composable annotation model in Spring.

    As a side note, there was a backwards compatibility concern with TypeDescriptor's legacy algorithm preferring inherited annotations over locally declared composed annotations. It turns out that this would only affect lookups on a Class whereas TypeDescriptor is only designed to work against fields and method parameters, so there was no reason to hold on to it.

  2. added
    type: enhancement
    in: core
    on Jan 11, 2019
  3. added this to the 4.3.4 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions