title: Java 8 (pre-release) interface member variables
body: <p>Are public members variables in Java 8 interfaces a feature or an implementation side-effect/defect?</p>
  
  <p>This question pertains to the pre-release Java 8 build <a href="http://jdk8.java.net/lambda/">lambda-8-b50-linux-x64-26_jul_2012.tar.gz</a>.</p>
  
  <p>Java 8 introduces new features to interfaces in the form of default methods. Casual testing with the JDK8 lambda compiler allows interfaces of this form:</p>
  
  <pre><code>public interface Foo {
    public int foo = 0;
    int foo() default { return foo; }
  }
  </code></pre>
  
  <p>Sample implementing type:</p>
  
  <pre><code>public class FooImpl implements Foo {
    public int foo = 1;
  }
  </code></pre>
  
  <p>This code follows the standard conventions for variable shadowing:</p>
  
  <pre><code>Foo f = new FooImpl();
  System.out.println(f.foo());
  System.out.println(f.foo);
  System.out.println(new FooImpl().foo);
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>0
  0
  1
  </code></pre>
  
  <p>The documentation (JSR 335: Lambda Expressions for the Java™ Programming Language Version 0.5.1) doesn't mention member variables. I'm inclined to think the compiler is being too tolerant but perhaps I've missed something.</p>