SYL
SYL

Reputation: 155

Compiling case class with many parameters causes java.lang.StackOverflowError

I have the following case class with very large number of parameters (150) is causing java.lang.StackOverflowError exception during compilation using sbt (version 0.14):

class definition:

case class TestClass(Param1:String,Param2:String,Param3:String,...,Param150:String)

Exception during sbt compilation:

[info] Compiling 1 Scala source to C:\spark-2.2.0-bin-hadoop2.7\ImportSyncPuffDataApp\target\scala-2.11\classes...
java.lang.StackOverflowError
        at scala.tools.nsc.typechecker.Contexts$Context.bufferErrors(Contexts.scala:332)
        at scala.tools.nsc.typechecker.Contexts$Context.reportErrors(Contexts.scala:333)
...
        at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:680)
        at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4524)
[error] (compile:compileIncremental) java.lang.StackOverflowError

If reduce the number of parameters to 115, it works fine. How can I work around this limit?

Upvotes: 2

Views: 2760

Answers (2)

pedromorfeu
pedromorfeu

Reputation: 1949

Use sbt command line to increase stack size (through JVM parameters):

sbt -J-Xss2M -J-Xmx2G

Upvotes: 0

jiayp89
jiayp89

Reputation: 533

Give a larger jvm stack space(default 1M) by add this:

-Xss2M

On windows platform it should be in %SBT_HOME%\conf\sbtconfig.txt

Upvotes: 1

Related Questions