InfiniteRecursion
This method always recurses, and will cause a StackOverflowError

Severity
ERROR

The problem

A method that always calls itself will cause a StackOverflowError.

int oops() {
  return oops();
}
Exception in thread "main" java.lang.StackOverflowError
  at Test.oops(X.java:3)
  at Test.oops(X.java:3)
  ...

The fix may be to call another method with the same name:

void process(String name, int id) {
  process(name, id); // error
  process(name, id, /*verbose=*/ true); // ok
}

void process(String name, int id, boolean verbose) {
  // ...
}

or to call the method on a different instance:

class Delegate implements Processor {
  Processor delegate;

  void process(String name, int id) {
    process(name, id); // error
    delegate.process(name, id); // ok
  }
}

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("InfiniteRecursion") to the enclosing element.