Annotation is not inherited from interface method

前端 未结 3 1725
一个人的身影
一个人的身影 2021-01-17 12:27

I have an interface with an annotated method. The annotation is marked with @Inherited, so I expect an implementor to inherit it. However, it is not the case:

3条回答
  •  失恋的感觉
    2021-01-17 12:33

    From the @Inherited javadoc:

    Note that this meta-annotation type has no effect if the annotated type is used to annotate anything other than a class. Note also that this meta-annotation only causes annotations to be inherited from superclasses; annotations on implemented interfaces have no effect.`

    In summary, it doesn't apply to methods.

提交回复
热议问题