I have two different copies of scala version 2.9.2 from the Scala-Lang website.
No. 1 is binary code: scala-2.9.2.tgz
No. 2 is source code: scala-sources-2.9.2.tgz
I built scala from the source code. I have tried using both in an application and the binary works but the compiled source code does not.
My use case: I am compiling a tiny scala file that I wrote (see below for an example), then creating a jar, and then running "main" from within that jar on the command line. To make that jar, I must include "scala-library.jar" (from this SO answer) on the classpath. I need to be able to use the scala-sources that I build so that I can modify the source code later on.
When I use the compiled source code, I get an error regarding serialVersionUID, whereas the binary code does not cause this issue.
Exact error message (when using the scala that I build from source):
java.io.InvalidClassException: scala.collection.mutable.WrappedArray$ofRef; local class incompatible: stream classdesc serialVersionUID = 8184381945838716286, local class serialVersionUID = 6238838760334617323
Example code that I am running for deserializing a file:
object test {
def main(args: Array[String]) {
var infile = args(0)
val thing1 : MyClass = withObjectInput(infile) {
f => f.readObject().asInstanceOf[MyClass]
}
}
}
If
MyClass
doesn't explicitly supply aserialVersionUID
, the the compiler generates one. This will be different for different versions of javac used when compiling it.So this error will be caused by a mismatch between the version of javac that you used for compiling scala-library and the version that was used for the downloaded binary.