Files
openide/java/java-impl/resources/inspectionDescriptions/ClassGetClass.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

22 lines
793 B
HTML

<html>
<body>
Reports <code>getClass()</code> methods that are called on a <code>java.lang.Class</code> instance.
<p>This is usually a mistake as the result is always equivalent to <code>Class.class</code>.
If it's a mistake, then it's better to remove the <code>getClass()</code> call and use the qualifier directly.
If the behavior is intended, then it's better to write <code>Class.class</code> explicitly to avoid confusion.</p>
<p>Example:</p>
<pre><code>
void test(Class&lt;?&gt; clazz) {
String name = clazz.getClass().getName();
}
</code></pre>
<p>After one of the possible quick-fixes is applied:</p>
<pre><code>
void test(Class&lt;?&gt; clazz) {
String name = clazz.getName();
}
</code></pre>
<!-- tooltip end -->
<p><small>New in 2018.2</small></p>
</body>
</html>