@Inherited
@Inherited 注解的作用
@Inherited 用于放在注解上,例如
(ElementType.TYPE) public @interface InheritedAnno { }
当@InheritedAnno注解加在某个类A上时,假如类B继承了A,则B也会带上该注解。
类继承关系中@Inherited的作用
类继承关系中,子类会继承父类使用的注解中被@Inherited修饰的注解
接口继承关系中@Inherited的作用
接口继承关系中,子接口不会继承父接口中的任何注解,不管父接口中使用的注解有没有被@Inherited修饰
类实现接口关系中@Inherited的作用
类实现接口时不会继承任何接口中定义的注解