Inspectopedia
 
2024.3

Overly strong type cast

Warning
New
Last modified: 03 December 2024

Reports type casts that are overly strong. For instance, casting an object to ArrayList when casting it to List would do just as well.

Note: much like the Redundant type cast inspection, applying the fix for this inspection may change the semantics of your program if you are intentionally using an overly strong cast to cause a ClassCastException to be generated.

Example:

Use the checkbox below to ignore casts when there's a matching instanceof check in the code.