6

I have a syntactically correct Scala source file holding a huge data structure. The code looks like this:

object ChiSquareAlpha
{
  val ChiSquareToAlphaIndexTable = Map(
    1 -> Array(0.00016,0.00063,0.00393,0.01579,0.06418,0.14847,0.45494,1.07419,1.64237,2.70554,3.84146,5.41189,6.63490,10.82757),
    .. 9998 other entries ..
    10000 -> Array(9673.95,9711.71,9768.53,9819.19,9880.79,9925.36,9999.33,10073.68,10118.82,10181.66,10233.75,10292.58,10331.93,10442.73)
  )
}

So you can see, the object holds a huge lookup table, a Map[Int, Array[Double]] with 10000 entries. Compilation takes about a minute, but finishes without warnings or errors. But at runtime it fails with:

java.lang.ClassFormatError: Invalid this class index 4280 in constant pool in class file bm/statistic/ChiSquareAlpha$
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.scala$tools$nsc$util$ScalaClassLoader$$super$findClass(ScalaClassLoader.scala:88)
at scala.tools.nsc.util.ScalaClassLoader$class.findClass(ScalaClassLoader.scala:44)
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.findClass(ScalaClassLoader.scala:88)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.scala$tools$nsc$util$ScalaClassLoader$$super$loadClass(ScalaClassLoader.scala:88)
at scala.tools.nsc.util.ScalaClassLoader$class.loadClass(ScalaClassLoader.scala:50)
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.loadClass(ScalaClassLoader.scala:88)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at bm.statistic.ChiSquareTest.testOfIndependence(ChiSquareTest.scala:323)
at ...

I tested this with scala 2.9.2 and scala 2.10. Same result. When the object is much smaller - let's say 500 map entries - the program works. So I guess scala is unable to deal with such big files. Any solution proposals?

4

1 回答 1

7

你是对的,你的语法看起来不错。

对于令人失望的答案,我深表歉意,这是Scala的一个开放错误:

Scala 编程语言 SI-6543 scala 编译在简单但冗长的重复脚本上失败(ClassNotFound 和/或 StackOverflowError)

它的修复优先级是 Major(很高),您可以找到有关它的更多信息(他们解释它发生的原因)。

您可以跟踪进度。同时,您可以在平面文件中创建该信息并从中读取数据作为临时修复。

于 2013-05-11T17:37:50.370 回答