There are three reasons for a method not to have a method body:
UnsupportedOperationException
should be thrown.The following code snippet:
// Non-Compliant public void doSomething() { }should be refactored into:
// Compliant @Override public void doSomethingElse() { // Do nothing because of X and Y. }or:
// Compliant @Override public void doSomethingElse() { throw new UnsupportedOperationException(); }
Empty methods not having any nested comments are tolerated in Abstract classes as those empty methods are usual when implementing the visitor pattern.