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

32 lines
1.1 KiB
HTML

<html>
<body>
Reports usages of concrete classes, rather than interfaces.
Such declarations may represent a failure of abstraction and may make testing more difficult.
<p>
Declarations whose classes come from system or third-party libraries will not be reported by this inspection.
Casts, instanceofs, and local variables are not reported in <code>equals()</code> method implementations.
Also, casts are not reported in <code>clone()</code> method implementations.
</p>
<p>Example:</p>
<pre><code>
interface Entity {}
class EntityImpl implements Entity {}
void processObject(Object obj) {
// warning: instanceof of the concrete class
if (obj instanceof EntityImpl) {
// warning: cast to the concrete class,
// rather than the interface
processEntity((EntityImpl)obj);
}
}
// warning: parameter of concrete class
void processEntity(EntityImpl obj) {
}
</code></pre>
<!-- tooltip end -->
<p>
Use the <b>Ignore abstract class type</b> option to ignore casts to abstract classes.</p>
<p>Use the subsequent options to control contexts where the problem is reported.</p>
</body>
</html>