Files
openide/java/java-impl/resources/inspectionDescriptions/LocalVariableHidingMemberVariable.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.0 KiB
HTML

<html>
<body>
Reports local variables named identically to a field of a surrounding class.
As a result of such naming, you may accidentally use the variable where the identically named field is intended.
<p>A quick-fix is suggested to rename the variable.</p>
<p><b>Example:</b></p>
<pre><code>
public class Foo {
public Object foo;
void bar() {
Object o = new Object() {
void baz() {
Object foo; // Local variable 'foo' hides field in class 'Foo'
}
};
}
}
</code></pre>
<!-- tooltip end -->
<p>
You can configure the following options for this inspection:
</p>
<ol>
<li><strong>Ignore non-accessible fields</strong> - ignore local variables named identically to superclass fields
that are not visible (for example, because they are private).</li>
<li><strong>Ignore local variables in a static context hiding non-static fields</strong> -
for example when the local variable is inside a static method or inside a method which is inside a static inner class.
</li>
</ol>
</body>
</html>