-
Bug
-
Resolution: Fixed
-
P4
-
8u40
-
b63
-
x86_64
-
linux
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8085493 | emb-9 | Jan Lahoda | P4 | Resolved | Fixed | team |
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
javac -version
javac 1.8.0_40
ADDITIONAL OS VERSION INFORMATION :
Linux 3.16.7-ckt5-sk+ #1 SMP Tue Feb 17 22:00:49 EST 2015 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
When performing a particular set of specific operations when initializing a `static final` field, javac overflows the stack.
It appears as if the combination of String append and performing a map operation on a stream cause this behavior.
Behavior noticed by user on reddit forum (not me, although I have reproduced it): https://www.reddit.com/r/learnprogramming/comments/32bfle/can_you_explain_this_strange_java8_error/
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attempt to compile provided source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compilation
ACTUAL -
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:2609)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2275)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
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:2609)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2275)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
at com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2404)
at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class uncompilable
{
static final List<String> stringList = Arrays.asList("doesnt", "matter");
static final String finalJoinedMappedAppendedString = "" + fakeJoin(stringList.stream().map(str -> str).collect(Collectors.toList()));
private static String fakeJoin(List<String> doesntMatter) {
return "anything";
}
public static void main(String[] args) { }
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
From forum post:
"Oh and additionally, if you put the stream/map/collect calls into a random static function and call that instead, it all works fine. It just dislikes being directly attached to the static final field."
- backported by
-
JDK-8085493 Initializing static fields causes unbounded recursion in javac
- Resolved
- duplicates
-
JDK-8143898 javac StackOverflow in final field initialization with lambda and string concat
- Closed
-
JDK-8145181 Compile Failure with Stream processing and String Concatenation
- Closed
-
JDK-8166672 javac stack overflow when compiling lambda
- Closed
-
JDK-8179504 Compiler dies with NullPointerException with stream and lambda on initializing static final field
- Closed
-
JDK-8184750 Adding final modifier to a string variable causes stack overflow error
- Closed
-
JDK-8227678 Javac compilation issues when compiling static expressions that use Lambda
- Closed