Search code examples
javaoverridingjavadoc

How to override method's javadoc without overriding the method itself?


Say I have two classes:

public abstract class AbstractFoo {

    /**
     * Do bar. Subclasses may override this method, it is not required that they do baz.
     */
    public void bar() {
        // default implementation
    }

}

public class ConcreteFoo extends AbstractFoo {

    /**
     * Do bar. <b>Note:</b> does not do baz, you have to do it yourself.
     */
    @Override
    public void bar() {
        super.bar();
    }
}

In the subclass (ConcreteFoo) I want to override bar()'s javadoc but keep the implementation as in the super class (AbstractFoo). Is there any way to do this without overriding the method?


Solution

  • No there is absolutely no way of doing that.
    You should, however, use the

    /**
     * {@inheritDoc}
     * add whatever you would like here
     */
    

    notation as the implementation javadoc, if you plan on really overriding the method.