summaryrefslogtreecommitdiff
path: root/plugins/InspectionGadgets/src/inspectionDescriptions/AmbiguousFieldAccess.html
blob: c8c714b78f40d760aa14a071bae2f5475bca84ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<html>
<body>
Reports ambiguous accesses of a super class field from an inner or anonymous class, where a local variable, parameter or field with identical name is available
in the surrounding code. In this situation a cursory examination of the code may suggest that an element in the surrounding code is
accessed, when in actual fact a field from the super class is accessed. To clarify the intent of the code it is recommended to add a
<b>super</b> qualifier to the field access.
<p>Example:
<pre><code>
<b>class</b> X {
  <b>protected</b> String s;
}
<b>class</b> Y {
  <b>void</b> foo(String s) {
    <b>new</b> X() {{
      System.out.println(s); // here the field is accessed not the parameter
    }};
  }
}
</code></pre>
<!-- tooltip end -->
<p>
</body>
</html>