Inspectopedia
 
2024.3

Suspicious 'Class.getClass()' call

Warning
New
Last modified: 03 December 2024

Reports getClass() methods that are called on a java.lang.Class instance.

This is usually a mistake as the result is always equivalent to Class.class. If it's a mistake, then it's better to remove the getClass() call and use the qualifier directly. If the behavior is intended, then it's better to write Class.class explicitly to avoid confusion.

Example:

After one of the possible quick-fixes is applied:

New in 2018.2