Inspectopedia Help

Redundant 'throws' clause

Reports exceptions that are declared in a method's signature but never thrown by the method itself or its implementations and overriding methods.

The inspection ignores methods related to serialization, for example the methods readObject() and writeObject().

Example:

void method() throws InterruptedException { System.out.println(); }

The quick-fix removes unnecessary exceptions from the declaration and normalizes redundant try-catch statements:

void method() { System.out.println(); }

Note: Some exceptions may not be reported during in-editor highlighting for performance reasons. To see all results, run the inspection by selecting Code | Inspect Code or Code | Analyze Code | Run Inspection by Name from the main menu.

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

RedundantThrows
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Declaration redundancy

Use the Ignore exceptions thrown by entry point methods option to not report exceptions thrown by for example main() methods. Entry point methods can be configured in the settings of the Java | Declaration redundancy | Unused declaration inspection.

Inspection options

Here you can find the description of settings available for the Redundant 'throws' clause inspection, and the reference of their default values.

Ignore exceptions thrown by entry point methods

Not selected

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.2, Qodana for JVM 2024.2,

Can be installed with plugin:

Java, 242.22892

Last modified: 11 September 2024