The reason why it seems to work fine on Hotsopt is just that Hotspot copes better with StackOverflowErrors than Avian and is in a less broken state after catching the SOE:
Don't be mistaken: Even on Hotspot stringifying XML values causes SOEs which are then catched and thrown away.
Stacktraces look like this:
...
scala> val atom = new scala.xml.Atom()
java.lang.ExceptionInInitializerError
at scala.xml.Node.buildString(Node.scala:162)
at scala.runtime.ScalaRunTime$.scala$runtime$ScalaRunTime$$inner$1(ScalaRunTime.scala:313)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
at scala.collection.TraversableOnce$class.addString(TraversableOnce.scala:343)
at scala.collection.TraversableOnce$class.mkString(TraversableOnce.scala:309)
at scala.runtime.ScalaRunTime$.scala$runtime$ScalaRunTime$$inner$1(ScalaRunTime.scala:316)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
at scala.collection.TraversableOnce$class.addString(TraversableOnce.scala:343)
at scala.collection.TraversableOnce$class.mkString(TraversableOnce.scala:309)
...
or
...
java.lang.NoClassDefFoundError: scala.xml.Utility$
at scala.xml.Node.buildString(Node.scala:162)
at scala.runtime.ScalaRunTime$.scala$runtime$ScalaRunTime$$inner$1(ScalaRunTime.scala:313)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
at scala.collection.TraversableOnce$class.addString(TraversableOnce.scala:343)
at scala.collection.TraversableOnce$class.mkString(TraversableOnce.scala:309)
at scala.runtime.ScalaRunTime$.scala$runtime$ScalaRunTime$$inner$1(ScalaRunTime.scala:316)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
...
Caused by: java.lang.StackOverflowError
... 10888 more
I started to see two new test failures on Avian, but the issue exists on all runtimes.
The code ends up in an endless recursion by the changes to the stringOf method in ScalaRuntime (https://github.com/scala/scala/commit/739cc9d1ad8b7d1def468299c9cdc6e9ebb2d143#src/library/scala/runtime/ScalaRunTime.scala).
The reason why it seems to work fine on Hotsopt is just that Hotspot copes better with StackOverflowErrors than Avian and is in a less broken state after catching the SOE:
Don't be mistaken: Even on Hotspot stringifying XML values causes SOEs which are then catched and thrown away.
Stacktraces look like this:
or