Aladdin - Scala Bugtracking
[#975] project: compiler priority: low category: bug
submitter assigned to status date submitted
Burak Burak fixed 2007-03-02 17:54:34.0
subject mutable.ListBuffer not serializable
code
package test;

import scala.collection.mutable.ListBuffer
import java.io.ByteArrayOutputStream
import java.io.ObjectOutputStream

object serial extends scala.Application
{
  override def main (args : Array[String]) : Unit = {
    val v = new ListBuffer[Int]()
    v += 1
    Console.out.println(v)

    val baos = new ByteArrayOutputStream()
    val oos = new ObjectOutputStream(baos)
    //oos.writeObject(v.toList) // ok
    oos.writeObject(v) // java.io.NotSerializableException: scala.collection.mutable.ListBuffer
    oos.close()
  }
}
what happened
java.io.NotSerializableException: scala.collection.mutable.ListBuffer
        at java.io.ObjectOutputStream.writeObject0(Unknown Source)
        at java.io.ObjectOutputStream.writeObject (Unknown Source)
        ....
what expected
[back to overview]
Changes of this bug report
Burak  edited on  2007-03-02 18:08:12.0
adding @serializable solved the problem
Stephane  edited on  2007-03-02 18:46:21.0
added @serializable annotation to ListBuffer in rev 10177