JDK-8184750 : Adding final modifier to a string variable causes stack overflow error
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2017-07-15
  • Updated: 2017-08-02
  • Resolved: 2017-07-17
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Mac 10.12.4

A DESCRIPTION OF THE PROBLEM :
adding final modifier to a string variable causes stack overflow error.


ERROR MESSAGES/STACK TRACES THAT OCCUR :
Information:java: The system is out of resources.
Information:java: Consult the following stack trace for details.
Information:java: 	at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2296)
Information:java: 	at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
Information:java: 	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
Information:java: 	at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2435)
Information:java: Errors occurred while compiling module 'server'
Information:javac 1.8.0_121 was used to compile java sources
Information:7/14/17, 6:29 PM - Compilation completed with 45 errors and 100 warnings in 5s 804ms
Error:java: java.lang.StackOverflowError

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
private static final String UPDATE_PERMISSIONS_LIST = "Test " + String.join(",", Stream.of(test.values())
      .map(perm -> perm.name() + "=?").collect(Collectors.toList())) ;


public enum test {
    one,
    two,
    three
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
// not using final fixes.

private static String UPDATE_PERMISSIONS_LIST = "Test " + String.join(",", Stream.of(test.values())
      .map(perm -> perm.name() + "=?").collect(Collectors.toList())) ;


Comments
This issue is reproducible in 8u152, 8u131 but not in 9 ea b178 It is duplicate of JDK-8077605 which got fixed in 9 ea b63. It is clear from the below results == 9 ea b62 - Fail 9 ea b63 - Pass //Fixed here 9 ea b178 - Pass 8u131 - Fail 8u152 - Fail
17-07-2017