既然 22 不再是限制,Scala 案例 class 允许的实际最大字段数是多少?
What is the practical maximum number of fields allowed in a Scala case class now that 22 is no longer the limit?
我有一个生成编译时堆栈溢出错误的项目。
我正在使用 Quill 进行持久化,它使用宏。我有一个案例 class,其中包含 600 多个字段,代表一个数据库 table.
在编译期间我得到以下无限递归:
ervice.scala:27: UPDATE email_user SET password_hash = ? WHERE user_id
= ? [info] .run(quote { [info] ^ java.lang.WhosebugError at
scala.tools.nsc.transform.Erasure$Eraser.adaptMember(Erasure.scala:686)
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:773)
at
scala.tools.nsc.typechecker.Typers$Typer.runTyper(Typers.scala:5584)
at
scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5616)
at scala.tools.nsc.typechecker.Typers$Typer.body(Typers.scala:5557)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5562)
at
scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1(Typers.scala:4708)
at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:698)
at
scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply(Typers.scala:4710)
at
scala.tools.nsc.typechecker.Typers$Typer.typedApply(Typers.scala:4757)
at
scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode(Typers.scala:5530)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5547)
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:773)
at
scala.tools.nsc.typechecker.Typers$Typer.runTyper(Typers.scala:5584)
即使案例字段数量的 22 个字段限制现在已经消失,我是否遇到了一些实际限制?
如果我没有使用 Quill 访问有问题的 table/huge 案例 class,就会出现此编译错误。
感谢您的任何见解!
如果您想将其称为实际限制,那么您遇到了正在编译的 JVM 的最大堆栈大小。
如果要编译嵌套异常深的代码或使用异常大的 case 类,则必须增加 JVM 的堆栈大小被认为是正常的。通过将参数 -Xss6m
传递给 JVM,您可以将最大堆栈大小设置为 6MB。您可以尝试增加该数字直到有效。
我有一个生成编译时堆栈溢出错误的项目。
我正在使用 Quill 进行持久化,它使用宏。我有一个案例 class,其中包含 600 多个字段,代表一个数据库 table.
在编译期间我得到以下无限递归:
ervice.scala:27: UPDATE email_user SET password_hash = ? WHERE user_id = ? [info] .run(quote { [info] ^ java.lang.WhosebugError at scala.tools.nsc.transform.Erasure$Eraser.adaptMember(Erasure.scala:686) at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:773) at scala.tools.nsc.typechecker.Typers$Typer.runTyper(Typers.scala:5584) at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5616) at scala.tools.nsc.typechecker.Typers$Typer.body(Typers.scala:5557) at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5562) at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1(Typers.scala:4708) at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:698) at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply(Typers.scala:4710) at scala.tools.nsc.typechecker.Typers$Typer.typedApply(Typers.scala:4757) at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode(Typers.scala:5530) at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5547) at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:773) at scala.tools.nsc.typechecker.Typers$Typer.runTyper(Typers.scala:5584)
即使案例字段数量的 22 个字段限制现在已经消失,我是否遇到了一些实际限制?
如果我没有使用 Quill 访问有问题的 table/huge 案例 class,就会出现此编译错误。
感谢您的任何见解!
如果您想将其称为实际限制,那么您遇到了正在编译的 JVM 的最大堆栈大小。
如果要编译嵌套异常深的代码或使用异常大的 case 类,则必须增加 JVM 的堆栈大小被认为是正常的。通过将参数 -Xss6m
传递给 JVM,您可以将最大堆栈大小设置为 6MB。您可以尝试增加该数字直到有效。