Inspectopedia Help

Instantiating object to get 'Class' object

Reports code that instantiates a class to get its class object.

It is more performant to access the class object directly by name.


Class<?> c = new Sample().getClass();

After the quick-fix is applied:

Class<?> c = Sample.class;

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3


Java, 233.SNAPSHOT

Last modified: 13 July 2023