Inspectopedia
 
2024.3

Redundant 'throws' clause

Warning
New
Last modified: 03 December 2024

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:

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

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.

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.