Back to Error Prone

InvalidThrows

docs/bugpattern/javadoc/InvalidThrows.md

2.49.0338 B
Original Source

The @throws tag should not document a checked exception which is not actually thrown by the documented method.

java
/**
 * Validates {@code n}.
 *
 * @throws Exception if n is negative.
 */
void validate(int n) {
  ...
}

Suppression

Suppress by applying @SuppressWarnings("InvalidThrows") to the element being documented.