java - StackOverflowError 在 IntelliJ 上使用 Scala

标签 java scala intellij-idea

我正在尝试使用 Gradle 在 IntelliJ 上构建一个 Scala 项目。我能够编译,但编译一直失败并出现堆栈溢出错误。

我查看了其他有类似问题的帖子,建议增加堆/堆栈大小(thisthis)。到目前为止,我已经尝试在 JAVA_OPTS 和 idea64.exe.vmoptions 中设置它们。

-Xss512m -Xms512m -Xmx2048m -XX:ReservedCodeCacheSize=64m -ea

我也试过包括 -XX:MaxPermSize=2048m 也没有用(相信它在 Java 8 中不受支持)。

相同的代码为具有相同配置的另一个人构建。任何人都可以阐明我所缺少的东西吗?

详细信息:

IntelliJ Ultimate 2016.1
Scala 2.10.3
Java 1.8.0_92

堆栈跟踪:

java.lang.StackOverflowError
    at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:696)
    at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
    at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
    at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
    at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
    at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$96.apply(Typers.scala:4523)
    at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$96.apply(Typers.scala:4523)
    at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:680)
    at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4522)
    at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4578)
    at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5343)
    at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5360)
    at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:696)
    at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
    at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
    at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
    at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
    at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:5472)
    at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:5480)
    at scala.tools.nsc.transform.Erasure$Eraser.adaptMember(Erasure.scala:642)
    at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:696)
    at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
    at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
    at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
    at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
    at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$96.apply(Typers.scala:4523)
    at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$96.apply(Typers.scala:4523)
    at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:680)
    at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4522)
    at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4578)

最佳答案

异常来自 IntelliJ 使用的编译器,因此您需要更改编译器构建过程的堆大小。前往

File -> Settings -> Build, Execution, Deployment -> Compiler -> Build process 
heap size (Mbytes)

将此属性增加到更高的值。

Screenshot showing the settings pane increasing the value to 1024 MBytes

关于java - StackOverflowError 在 IntelliJ 上使用 Scala,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43194204/

相关文章:

java - 我需要 Java 中的三元运算符,如果条件为真,它会分配两个变量

scala - java.sql.SQLException -> 在 spark 的 DataFrame 上使用 .show() 方法时出现 NumberFormatException

Try[Int] 的 Scala 类型错误

java - 使引用不可变?

java - 从动态加载的 jar 文件中加载具有父类(super class)的 Java 类

java - IntelliJ IDE 在将 Try-Catch 与资源一起使用时出错

java - 有没有办法通过使用 Intellij 添加外部方法调用来重构?

javascript - 如何查看 IntelliJ 中的所有 jslint 错误?

java - 使用 peek 和 findAny 对 Java Stream 结果感到困惑

ruby-on-rails - Scala + Lift 或 Ruby on Rails,适合初学者