Java about @Override



那么覆盖的问题是什么呢?我不明白:

@Override
public ProtocolEncoder getEncoder(IoSession session) throws Exception {
    return encoder;
}
@Override
public ProtocolDecoder getDecoder(IoSession session) throws Exception {
    return decoder;
}

错误:

error: method does not override or implement a method from a supertype
@Override
error: MaplePacketDecoder is not abstract and does not override abstract method doDecode(IoSession,ByteBuffer,ProtocolDecoderOutput) in CumulativeProtocolDecoder
public class MaplePacketDecoder extends CumulativeProtocolDecoder {
error: method write in interface ProtocolEncoderOutput cannot be applied to given types;
                out.write(IoBuffer.wrap(ret));
  required: ByteBuffer
  found: IoBuffer
  reason: actual argument IoBuffer cannot be converted to ByteBuffer by method invocation conversion

您忘记实现doDecode(IoSession,ByteBuffer,ProtocolDecoderOutput)

您试图用不同的参数(不同的签名)重写超类中的方法。重写的方法必须匹配被重写的方法的签名(在父类中)。

http://docs.oracle.com/javase/tutorial/java/IandI/override.html

似乎您试图覆盖的方法名称或您提供的参数不正确。你也不实现doDecode方法从CumulativeProtocolDecoder。如果CumulativeProtocolDecoder是一个抽象类,你应该实现它

相关内容

  • 没有找到相关文章