今天在用 “debug” 模式运行 maven 的 jetty:run
时,出现了 java.lang.StackOverflowError
,具体的栈信息如下:
The system is out of resources. Consult the following stack trace for details. java.lang.StackOverflowError at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062) at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418) at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460) at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062) at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418) at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460) at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062) at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418) at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460) at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062) ...此处省略 N 个重复的
Google 了一下 ,了解到解决 java.lang.StackOverflowError
的一种办法是增大栈的大小:
-Xss你想增加到的大小
由于我是用 idea 启动的 debug,所以要在 idea 中设置 ,设置选项的位置如下:
调成了栈大小后,重新 debug 发现不再 StackOverflowError 了。