title: NullPointerException when using Predicate during static field initialization
body: <p>Could someone explain what is causing the NPE in the following example code. It seems to be something to do with how static fields (in particular the <code>Predicate</code>) are initialized maybe, but I can't quite figure out what is going on.</p>
  
  <pre><code>import java.util.Arrays;
  import java.util.List;
  import java.util.function.Predicate;
  import java.util.stream.Collectors;
  
  public class Foo {
      public static List&lt;Integer&gt; stuff = doStuff();
      private static Predicate&lt;Integer&gt; bar = i -&gt; i == 42;
  
      public static int howBigIsStuff(){
          return stuff.size();
      }
  
      private static List&lt;Integer&gt; doStuff(){
          // java.lang.NullPointerException 
          //    at java.util.Objects.requireNonNull(Objects.java:203)
          List&lt;Integer&gt; foo = Arrays.asList(1,2,42,42).stream()
                  .filter(bar)
                  .collect(Collectors.toList());
          return foo;
      }
  }
  
  
  import java.util.Arrays;
  import java.util.List;
  import java.util.function.Predicate;
  import java.util.stream.Collectors;
  import org.junit.Test;
  
  public class FooTest {
  
      private static Predicate&lt;Integer&gt; bar = i -&gt; i == 42;
  
      @Test
      public void test() {
          // This is fine
          List&lt;Integer&gt; foo = Arrays.asList(1,2,42,42).stream()
                  .filter(bar)
                  .collect(Collectors.toList());
          System.out.println(foo);    // [42, 42]
  
          Foo.howBigIsStuff();
      }
  }
  </code></pre>