summaryrefslogtreecommitdiff
path: root/test/files/run/t9390c.scala
blob: db39da57cddd6c5830eb6d4c147594493e87ff0d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class C { // C is not serializable
  def foo = {
    { (x: Any) => new Object {} }
  }
}
object Test {
  def main(args: Array[String]): Unit = {
    val c = new C
    val f = c.foo
    val f1 = serializeDeserialize(f)
  }

  def serializeDeserialize[T <: AnyRef](obj: T): T = {
    import java.io._
    val buffer = new ByteArrayOutputStream
    val out = new ObjectOutputStream(buffer)
    out.writeObject(obj)
    val in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray))
    in.readObject.asInstanceOf[T]
  }
}