abstract class AbstractBootstrap<B extends AbstractBootstrap<B, C>, C extends Channel>{}
public final class ServerBootstrap extends AbstractBootstrap<ServerBootstrap, ServerChannel> {}
看netty源码看到这样的代码,看的很纠结,哪位高手解析下这种类型定义的意义在哪,或者说什么情况下这样定义。

解决方案 »

  1.   

    AbstractBootstrap<B extends AbstractBootstrap<B, C>, C extends Channel>{}
    第一个B代表了所有实现或继承了类AbstractBootstrap的实例
    C代表所有实现接口Channel的实例类
      

  2.   

    确实,ServerBootstrap extends AbstractBootstrap<ServerBootstrap, ServerChannel>,感觉先有AbstractBootstrap<ServerBootstrap, ServerChannel>这个类,才能定义ServerBootstrap这个类。但是这个类AbstractBootstrap<ServerBootstrap, ServerChannel>有包含ServerBootstrap这个类。搞不明白
      

  3.   

    这是声明了2个泛型类别,然后又用了自限定。《thinking in
    java》里面有很详细的解释