title: Why can method reference use non-final variables?
body: <p>I had some confusion about inner classes and lambda expression, and I tried to ask a <a href="https://stackoverflow.com/questions/33038239/lambda-expressions-reference-to-an-instance-method-of-a-particular-object">question</a> about that, but then another doubt arose, and It's probable better posting another question than commenting the previous one.</p>
  
  <p>Straight to the point: I know (<a href="https://stackoverflow.com/questions/4732544/why-are-only-final-variables-accessible-in-anonymous-class">thank you Jon</a>) that something like this won't compile </p>
  
  <pre><code>public class Main {
      public static void main(String[] args) {
          One one = new One();
  
          F f = new F(){      //1
              public void foo(){one.bar();}   //compilation error
          };
  
          one = new One();
      }
  }
  
  class One { void bar() {} }
  interface F { void foo(); }
  </code></pre>
  
  <p>due to how Java manages closures, because <code>one</code> is not <em>[effectively] final</em> and so on.</p>
  
  <p>But then, how come is this allowed?</p>
  
  <pre><code>public class Main {
      public static void main(String[] args) {
          One one = new One();
  
          F f = one::bar; //2
  
          one = new One();
      }
  }
  
  class One { void bar() {} }
  interface F { void foo(); }
  </code></pre>
  
  <p>Is not <code>//2</code> equivalent to <code>//1</code>? Am I not, in the second case, facing the risks of "working with an out-of-date variable"? </p>
  
  <p>I mean, in the latter case, after <code>one = new One();</code> is executed <code>f</code> still have an out of date copy of <code>one</code> (i.e. references the old object). Isn't this the kind of ambiguity we're trying to avoid?</p>