Pass down the argument value to an annotation

I am trying to create an annotation by combining annother’s functionality. Let’s say as below:

@Documented
@Retention(RUNTIME)
@Target({TYPE, METHOD})
@Around
@io.micronaut.tracing.annotation.NewSpan
public @interface NewSpan {
  String value() default "";
}

Now it’s seems impossible to pass the value to io.micronaut.tracing.annotation.NewSpan, after searching many other answers and java docs, it seems impossible to me, any help.

So when I use my @NewSpan("val"), it should be passed down to io.micronaut.tracing.annotation.NewSpan‘s value.

Thanks!

>Solution :

I believe that should be the same as in spring

@Documented
@Retention(RUNTIME)
@Target({TYPE, METHOD})
@Around
@io.micronaut.tracing.annotation.NewSpan
public @interface NewSpan {
  @AliasFor(annotation = io.micronaut.tracing.annotation.NewSpan.class, member="value")
  String value() default "";
}

Leave a Reply