jvz commented on issue #3870:
URL: 
https://github.com/apache/logging-log4j2/issues/3870#issuecomment-3175865685

   Alright, this turned out to be a bit different. I noticed some key insights 
into how the names and aliases are extracted:
   
   * All name and alias extractors operate on a single element of an annotation 
(i.e., only one method to call).
   * In fact, this is always the `value` element, but we can maintain some 
flexibility here.
   * The annotations always model this as either `String value()` or `String[] 
value()`.
   * For a name provider, this takes either the `String` value or the first 
element of the array.
   * For an alias provider, this either uses the whole `String[] value()` 
element (as in the case of `@PluginAliases`) or it uses all but the first 
element of the array (as in the case of `@Named` which works for both names and 
aliases).
   
   Thus, the whole scheme can be simplified into a couple updates:
   
   * `@NameProvider` needs to know which element of the annotation to get the 
name from (default is `value` as all our existing annotations use that one)
   * `@AliasesProvider` needs to know which element of the annotation to get 
the aliases from (default is also `value`), and it needs to know what offset to 
use in that array (default of 0)
   
   This reduces the maximum reflection usage here to only calling the `value` 
method (or whatever is specified in the annotation) on the annotated 
annotation. As a bonus, this makes it possible to use the annotation processor 
to index this information ahead of time and avoid reflection entirely, 
something that will be useful for GraalVM usage.
   
   As for how this changes things, it removes the need for using 
`AnnotatedElementNameProvider` and `AnnotatedElementAliasesProvider` entirely, 
removes those implementations, and simplifies the `@NameProvider` and 
`@AliasesProvider` sites to use default arguments most of the time.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to