gradle compileScala 出现 java.lang.StackOverflowError (no error message)

问题:

* What went wrong:
Execution failed for task ':data-model:compileScala'.
> java.lang.StackOverflowError (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 42s
2 actionable tasks: 2 executed
Cause: java.lang.StackOverflowError
	at scala.tools.nsc.typechecker.Contexts$Context.make(Contexts.scala:467)
	at scala.tools.nsc.typechecker.Contexts$Context.makeSilent(Contexts.scala:515)
	at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:675)
	at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4558)
    。。。。。。

原因:

scala case class 字段太多,我的有一百多个字段,导致栈溢出。

解决方案:

在build.gradle增加如下配制 :

    compileScala {
        options.fork = true
        options.forkOptions.jvmArgs += ["-Xss8M"]
    }

查找问题原因:

可以找到你的case class 字段最多的那个,然后用scalac xxx.scala单独编译,如果是和这个一样的问题,就会报java.lang.StackOverflowError (no error message), 然后再次执行scalac -JXss8M xxx.scala 应该就不会再保错。

默认的栈空间是1M, 给8M已足够大。

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值