<p>The code at the end produces a compile error:</p>

<pre><code>NotApplicable.java:7: run() in  cannot be applied to (int)
                run(42);
                ^
1 error
</code></pre>

<p>The question is why?  Why does javac think I am calling run(), and does not find run(int bar)?  It correctly called foo(int bar).  Why do I have to use NotApplicable.this.run(42);?  Is it a bug?</p>

<pre><code>public class NotApplicable {

    public NotApplicable() {
        new Runnable() {
            public void run() {
                foo(42);
                run(42);
                // uncomment below to fix
                //NotApplicable.this.run(42);
            }
        };
    }

    private void run(int bar) {
    }

    public void foo(int bar) {
    }
}
</code></pre>

This is because
```
run
```
is being re-declared when you enter the
```
new Runnable() {}
```
scope. All previous bindings to run become inaccessible. It's as if you were doing this:
```
```
import java.util.*;

public class tmp
{
  private int x = 20;
  public static class Inner
  {
      private List x = new ArrayList();
      public void func()
      {
          System.out.println(x + 10);
      }
  }

  public static void main(String[] args)
  {
    (new Inner()).func();
  }
}
```
```
The compiler won't look for something that matches the type of
```
x
```
all the way up the scope stack, it'll just halt when it finds the first references and sees that the types are incompatible.
NOTE:
It's not as if it
couldn't
do this... it's just that, to preserve your own sanity, it's been decided that it shouldn't.