Inherited的作用
用于修饰其他的Annotaion. 被修饰的Annotation在标注父类时,子类自动获得该标注:
@Inherited
public @interface MyAnnotation {}
public @interface MyAnnotation2 {}
@MyAnnotation
@MyAnnotation2
public class Base {}
public class Sub extends Base {}
Sub.class.getAnnotation(MyAnnotation.class) != null
Sub.class.getAnnotation(MyAnnotation2.class) == null