在学习netty5.0源码时,发现没有了之前的in-outbound的概念,而是通过AdapterAbstractChannelHandlerContext中skipFlags来区分的。skipFlags又是通过解析channelhandler类中方法的skip注解来获的。
后来就研究了下java注解的继承关系,发现有没有Inherited元注解,加在类还是方法上还是有些区分的。
看下元注解Inherited的注释:
* <p>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.
Inherited元注解只对类级别起作用,对接口和方法级别不起作用。
,总结下:
1.自定义METHOD级注解不加元注解Inherited,自定义注解加载父类方法上,那么子类如果override父类方法,那么子类getMethod(....).isAnnotationPresent(...)为false,是不继承父类的注解的,但是如果子类不override父类方法,结果是可以true,继承父类的注解;
2.将Inherit加到类级别自定义注解,父类加自定义注解,子类可以继承父类注解,子类getClass().isAnnotationPresent(....)为true。
不copy代码了,没意思。