blob: a6bafd0f49dc6e330e6ef134f16d1c800e9c423e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
class C { @inline final def f: Int => Int = (x: Int) => x + 1 }
object Test extends App {
import java.io._
def serialize(obj: AnyRef): Array[Byte] = {
val buffer = new ByteArrayOutputStream
val out = new ObjectOutputStream(buffer)
out.writeObject(obj)
buffer.toByteArray
}
def deserialize(a: Array[Byte]): AnyRef = {
val in = new ObjectInputStream(new ByteArrayInputStream(a))
in.readObject
}
def serializeDeserialize[T <: AnyRef](obj: T) = deserialize(serialize(obj)).asInstanceOf[T]
assert(serializeDeserialize((new C).f).isInstanceOf[Function1[_, _]])
}
|