From 7f37fa01a496b63a509533f3451f28c936d21743 Mon Sep 17 00:00:00 2001 From: michelou Date: Wed, 3 Oct 2007 16:52:05 +0000 Subject: enums can't be serialized --- src/library/scala/List.scala | 20 ++++++++++++-------- test/files/jvm/serialization.scala | 8 ++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala index 6e06b8e93f..e9edeafd7c 100644 --- a/src/library/scala/List.scala +++ b/src/library/scala/List.scala @@ -1226,24 +1226,28 @@ final case class ::[B](private var hd: B, private[scala] var tl: List[B]) extend import java.io._ - private def writeObject(out : ObjectOutputStream) = { + private def writeObject(out: ObjectOutputStream) { val i = elements while (i.hasNext) out.writeObject(i.next) out.writeObject(ListSerializeEnd) } - private def readObject(in : ObjectInputStream) : Unit = { + + private def readObject(in: ObjectInputStream) { hd = in.readObject.asInstanceOf[B] assert(hd != ListSerializeEnd) - var current : ::[B] = this + var current: ::[B] = this while (true) in.readObject match { - case ListSerializeEnd => current.tl = Nil; return - case a : Any => - val list : ::[B] = new ::(a.asInstanceOf[B], Nil) - current.tl = list - current = list + case ListSerializeEnd => + current.tl = Nil + return + case a : Any => + val list : ::[B] = new ::(a.asInstanceOf[B], Nil) + current.tl = list + current = list } } } + /** Only used for list serialization */ @SerialVersionUID(0L - 8476791151975527571L) private[scala] case object ListSerializeEnd diff --git a/test/files/jvm/serialization.scala b/test/files/jvm/serialization.scala index c3db752aa0..589e82c4c1 100644 --- a/test/files/jvm/serialization.scala +++ b/test/files/jvm/serialization.scala @@ -59,19 +59,19 @@ object Test1_scala { println("x1 = " + x1) println("y1 = " + y1) println("x1 eq y1: " + (x1 eq y1) + " - y1 eq x1: " + (y1 eq x1)) - println() + println println("x2 = " + x2) println("y2 = " + y2) println("x2 eq y2: " + (x2 eq y2) + " - y2 eq x2: " + (y2 eq x2)) - println() + println println("x3 = " + arrayToString(x3)) println("y3 = " + arrayToString(y3)) println("arrayEquals(x3, y3): " + arrayEquals(x3, y3)) - println() + println println("x4 = ") println("y4 = ") println("x4(2): " + x4(2) + " - y4(2): " + y4(2)) - println() + println } catch { case e: Exception => -- cgit v1.2.3