我使用scalaxb从xsd生成scala代码。(特别是我使用的是maven scalaxb插件)代码生成阶段运行得很顺利,通过观察它们,生成的scala文件看起来不错。但当我尝试编译时,堆栈溢出:

[ERROR] error: java.lang.StackOverflowError
[INFO]  at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:754)
[INFO]  at scala.tools.nsc.matching.MatrixAdditions$MatchMatrixOptimizer$lxtt$2$.transform(MatrixAdditions.scala:113)
[INFO]  at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:845)
[INFO]  at scala.tools.nsc.matching.MatrixAdditions$MatchMatrixOptimizer$lxtt$2$.transform(MatrixAdditions.scala:113)
[INFO]  at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:837)
[INFO]  at scala.tools.nsc.matching.MatrixAdditions$MatchMatrixOptimizer$lxtt$2$.transform(MatrixAdditions.scala:113)
[INFO]  at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:821)
[INFO]  at scala.tools.nsc.matching.MatrixAdditions$MatchMatrixOptimizer$lxtt$2$.transform(MatrixAdditions.scala:113)
[INFO]  at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:821)
[INFO]  at scala.tools.nsc.matching.MatrixAdditions$MatchMatrixOptimizer$lxtt$2$.transform(MatrixAdditions.scala:113)
[INFO]  at scala.tools.nsc.ast.Trees$Transformer.transform(Trees.scala:821)
[INFO]  at scala.tools.nsc.matching.MatrixAdditions$MatchMatrixOptimizer$lxtt$2$.transform(MatrixAdditions.scala:113)

...

[INFO]  at scala.collection.mutable.ListBuffer$$anon$1.foreach(ListBuffer.scala:311)
[INFO]  at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:294)
[INFO]  at scala.tools.nsc.transform.ExplicitOuter$Phase.run(ExplicitOuter.scala:539)
[INFO]  at scala.tools.nsc.Global$Run.compileSources(Global.scala:949)
[INFO]  at scala.tools.nsc.Global$Run.compile(Global.scala:1034)
[INFO]  at scala.tools.nsc.Main$.process(Main.scala:106)
[INFO]  at scala.tools.nsc.Main$.main(Main.scala:123)
[INFO]  at scala.tools.nsc.Main.main(Main.scala)
[INFO]  ... 6 more
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------

我使用的xsd已经过测试,并且可以与jaxb一起使用。
scala版本是2.9.0-1,scalaxb是0.6.2。

最佳答案

因此,根据op,通过将-Xss2048k放入jvmArg来解决问题。

关于xml - scalaxb生成的代码在编译期间导致堆栈溢出,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7486827/

10-09 05:25