Open
Description
This program
import java.io.ObjectOutputStream
import java.io.ByteArrayOutputStream
object SerializerBug {
def main(args: Array[String]): Unit = {
val a = 1
val b = "hello, world"
val obj = new {
val f = () => println(a.toString + " " + b)
}
obj.f()
new ObjectOutputStream(new ByteArrayOutputStream).writeObject(obj)
}
}
breaks with the following output:
1 hello, world
Exception in thread "main" java.io.NotSerializableException: SerializerBug$$anon$1
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
at SerializerBug$.main(SerializerBug.scala:14)
at SerializerBug.main(SerializerBug.scala)