StackOverflowError with many nested classes
See original GitHub issueParsing configs with relatively-deep hierarchies results in StackOverflowError using Scala 2.12.8.
// build.sbt
scalaVersion := "2.12.8"
"com.github.pureconfig" %% "pureconfig" % "0.11.0"
// Main.scala
import pureconfig._
import pureconfig.generic.auto._
object Main {
def main(args: Array[String]): Unit = {
val app = loadConfigOrThrow[AppConf]
println(s"app = ${app}")
}
}
case class AppConf(i: Int, a: A)
case class A(x: B)
case class B(x: C)
case class C(x: D)
case class D(x: E)
case class E(x: F)
case class F(x: G)
case class G(x: H)
case class H(x: Int)
Error message excerpts sbt clean compile
:
[info] Compiling 1 Scala source to ...
[error] ## Exception when compiling 1 sources to ...
[error] null
[error] scala.collection.LinearSeqOptimized.contains(LinearSeqOptimized.scala:104)
[error] scala.collection.LinearSeqOptimized.contains$(LinearSeqOptimized.scala:102)
[error] scala.collection.immutable.List.contains(List.scala:89)
[error] scala.reflect.internal.tpe.TypeConstraints$TypeConstraint.addHiBound(TypeConstraints.scala:144)
...
[error] scala.reflect.macros.contexts.Typers.inferImplicitValue(Typers.scala:56)
...
[error] shapeless.LazyMacros$DerivationContext$State$.resolveInstance(lazy.scala:304)
...
[error] java.lang.reflect.Method.invoke(Method.java:498)
...
[error] pureconfig.derivation.MacroCompat.inferImplicitValueCompat(MacroCompat.scala:36)
[error] pureconfig.derivation.MacroCompat.inferImplicitValueCompat$(MacroCompat.scala:27)
[error] pureconfig.DerivationMacros.inferImplicitValueCompat(Derivation.scala:31)
[error] pureconfig.DerivationMacros.materializeDerivation(Derivation.scala:79)
...
[error] scala.tools.nsc.Global$$anon$4.inferImplicitFor(Global.scala:477)
[error]
[error] java.lang.StackOverflowError
[error] at scala.collection.LinearSeqOptimized.contains(LinearSeqOptimized.scala:104)
[error] at scala.collection.LinearSeqOptimized.contains$(LinearSeqOptimized.scala:102)
[error] at scala.collection.immutable.List.contains(List.scala:89)
...
Note, the above example compiles well using Scala 2.11.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:10 (2 by maintainers)
Top Results From Across the Web
StackOverflowError when instantiating an object in another class
java.lang.StackOverflowError means that the stack has been burst. You have a recursive call, without a stop condition.
Read more >The StackOverflowError in Java - Baeldung
Learn how one of Java's most common errors - StackOverflowError - occurs, ... the end of method invocations found inside nested methods.
Read more >StackOverflowError in Java with examples - GeeksforGeeks
StackOverflowError is an error which Java doesn't allow to catch, ... when the end of the method invokes is found in the nested...
Read more >How to Fix java.lang.StackOverflowError in Java - Rollbar
The java.lang.StackOverflowError is a runtime error which points to serious problems that cannot be caught by an application. The java.lang.
Read more >StackOverflowError (Java Platform SE 7 ) - Oracle Help Center
Thrown when a stack overflow occurs because an application recurses too deeply. Since: JDK1.0; See Also: Serialized Form ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jcazevedo thx, it works like a charm. As there were 4 issues opened, it would might have sense to put a notice in docs about this behaviour? I’m closing the issue
I was building with gradle and finally got it to work with the following options scalaCompileOptions.forkOptions.jvmArgs = [‘-Xss2m’, ‘-XX:-UseGCOverheadLimit’]