title: getting StackOverflowError while initializing a static variable
body: <p>Below is the Minimal Verifiable Example of a piece of code which i stumbled upon.</p>
  
  <pre><code>package test_package;
  
  import java.util.function.Predicate;
  
  public class TestClass {
  
    public static final String CONST_STR = " some_data "+ getMoreData(e -&gt; e.getId()==3);
  
    private static String getMoreData(Predicate&lt;TestEnum&gt; p){
      StringBuilder sb = new StringBuilder();
      for(TestEnum e : TestEnum.values()){
        if(p.test(e)){
          sb.append(e.name());
        }
      }
      return sb.toString();
    }
  
    public static void main(String[] args) {
      System.out.println(CONST_STR);
    }
  }
  
  enum TestEnum{
    OP1(1),OP2(2),OP3(3);
  
    private final int id;
  
    public int getId() {
      return id;
    }
  
    TestEnum(int id){
      this.id = id;
    }
  }
  </code></pre>
  
  <p>when i am trying to compile it its giving me</p>
  
  <blockquote>
    <p>Error:java: java.lang.StackOverflowError</p>
  </blockquote>
  
  <p>can anyone point me where i am going wrong in it ?</p>
  
  <p>I am getting below error when trying to compile <code>javac test_package/TestClass.java</code></p>
  
  <blockquote>
    <p>The system is out of resources. Consult the following stack trace for
    details. java.lang.StackOverflowError     at
    com.sun.tools.javac.code.Scope.dupUnshared(Scope.java:144)    at
    com.sun.tools.javac.comp.Attr.lambdaEnv(Attr.java:2639)   at
    com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2305)     at
    com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)     at
    com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)   at
    com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)     at
    com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)     at
    com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)   at
    com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)     at
    com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)     at
    com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)   at
    com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)     at
    com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)     at
    com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)   at
    com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)     at
    com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)     at
    com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)   at
    com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)     at
    com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)     at
    com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)   at
    com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)     at
    com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)     at
    com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)   at
    com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)     at
    com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)     at
    com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)   at
    com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)     at
    com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)     at
    com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)   at
    com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)     at
    com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)     at
    com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)   at
    com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)     at
    com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)...</p>
  </blockquote>
  
  <p>and my version is <code>javac 1.8.0_112</code></p>
  
  <p>Thanks in Anticipation !</p>