A throw creates an instance of a broad base class that callers cannot single out

tx0/java:broad-throwstrictwarningsmell, cwe-397

What it finds

throw new RuntimeException("not found") gives callers nothing to tell this failure from any other: they can only catch every exception of that kind. A specific class, such as IllegalArgumentException or one of the program's own, can be caught on its own.

From the rule's source, broad_throw.rs.

Example from the rule's tests
class Accounts {  void withdraw(int amount) throws Exception {    if (amount < 0) {      throw new IllegalArgumentException("negative");    }    if (amount > 100) {      throw new RuntimeException("too much");tx0 reports: a generic RuntimeException is thrown    }    if (amount == 50) {      throw new Exception("odd");tx0 reports: a generic Exception is thrown    }  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:broad-throw" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:broad-throw] reason="..."

tx0 explain tx0/java:broad-throw shows the same in the terminal. Found a false positive? Report it.