title: Unexpected error using lambdas in Java 8
body: <p>I'm using Java 8 Update 20 32 bits, Maven 3.2.3, Eclipse Luna Build id: 20140612-0600 32 bits.</p>
  
  <p>After starting using lambdas, some classes in my projects started to report compilation errors in maven (<code>mvn compile</code>).</p>
  
  <p>These errors appears only when I use lambdas. If I switch back to anonymous classes, the errors are gone.</p>
  
  <p>I can reproduce the error with a simple test case:</p>
  
  <pre><code>package br;
  
  import java.awt.Button;
  import java.awt.Panel;
  
  public class Test {
  
      private final Button button;
      private final Panel panel;
  
      public Test() {
          button = new Button();
          button.addActionListener(event -&gt; {
              System.out.println(panel);
          });
          panel = new Panel();
      }
  }
  </code></pre>
  
  <p>I compile it this way:</p>
  
  <pre><code>mvn clean;mvn compile
  </code></pre>
  
  <p>And I get this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>[ERROR] /C:/Users/fabiano/workspace-luna/Test/src/main/java/br/Test.java:[14,44] variable panel might not have been initialized
  </code></pre>
  
  <p>Although the error message is pretty clear about what is happening (the compiler thinks the final variable <code>panel</code> is being called before it is instantiated), the variable will not be called until the button generates an action, and how we can't say when the action will happen, the code should compile. Indeed, it compiles as it should if I don't use lambdas:</p>
  
  <pre><code>package br;
  
  import java.awt.Button;
  import java.awt.Panel;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  public class Test {
  
      private final Button button;
      private final Panel panel;
  
      public Test() {
          button = new Button();
          button.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                  System.out.println(panel);
              }
          });
          panel = new Panel();
      }
  }
  </code></pre>
  
  <p>I noticed two other strange things related to this problem:</p>
  
  <ol>
  <li>Eclipse don't report this error when it auto-compile the class. Eclipse is using the same JDK as maven to compile the class.</li>
  <li>If I use maven to compile the class using anonymous classes, then I change the class to use lambdas and compile it using maven again, it doesn't report the error. In this case it just reports the error again if I use <code>mvn clean</code> followed by <code>mvn compile</code>.</li>
  </ol>
  
  <p>Can someone help me to fix this problem? Or try to reproduce this problem?</p>