Details

      Description

      Most of the collections lib is, and so it's pretty surprising that this isn't:

      scala> Map(1 -> 1).withDefaultValue(1)
      res9: scala.collection.immutable.Map[Int,Int] = Map(1 -> 1)
      
      scala> import java.io._
      import java.io._
      
      scala> val buffer = new ByteArrayOutputStream
      buffer: java.io.ByteArrayOutputStream = 
      
      scala> val out = new ObjectOutputStream(buffer)
      out: java.io.ObjectOutputStream = java.io.ObjectOutputStream@60232fff
      
      scala> out writeObject res9
      java.io.NotSerializableException: scala.collection.immutable.Map$WithDefault
      	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
      	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
      	at .<init>(<console>:41)
      	at .<clinit>(<console>)
      	at $anonfun$1.apply(<console>:7)
      	at $anonfun$1.apply(<console>:6)
      	at scala.tools.nsc.interpreter.Phased$class.atCurrent(Phased.scala:71)
      	at scala.tools.nsc.interpreter.Power$$anon$3.atCurrent(Power.scala:413)
      	at .<init>(<console>:6)
      	at .<clinit>(<console>)
      	at $print(<console>)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:775)
      	at scala.tools.nsc.interpreter.IMain$Request$$anonfun$18.apply(IMain.scala:1039)
      	at scala.tools.nsc.interpreter.Line.scala$tools$nsc$interpreter$Line$$runAndSetState(Line.scala:41)
      	at scala.tools.nsc.interpreter.Line$$anonfun$2.apply$mcV$sp(Line.scala:47)
      	at scala.tools.nsc.io.package$$anon$2.run(package.scala:22)
      	at java.lang.Thread.run(Thread.java:722)
      

        Issue Links

          Activity

          Hide
          Evan Chan added a comment -

          I have also hit this issue, please fix.

          Show
          Evan Chan added a comment - I have also hit this issue, please fix.
          Hide
          Alex Cruise added a comment -

          Also ImmutableDefaultKeySet

          Show
          Alex Cruise added a comment - Also ImmutableDefaultKeySet
          Hide
          Alex Cruise added a comment -

          Also DefaultValuesIterable

          Show
          Alex Cruise added a comment - Also DefaultValuesIterable
          Hide
          Evil Ipos added a comment -

          It's any technical reason why this cannot be fixed? It's annoying to use "m map identity" to send serialized map via network (to use for example with Akka)

          Show
          Evil Ipos added a comment - It's any technical reason why this cannot be fixed? It's annoying to use "m map identity" to send serialized map via network (to use for example with Akka)
          Hide
          Simon Ochsenreither added a comment -

          It seems like Map.WithDefault itself is not serializable, not some field/value of it (as I assumed first). So the fix would be to add Serializable to the right place. Right in the sense of either to the class itself or to a super class/trait. Not sure what's more correct.

          Show
          Simon Ochsenreither added a comment - It seems like Map.WithDefault itself is not serializable, not some field/value of it (as I assumed first). So the fix would be to add Serializable to the right place. Right in the sense of either to the class itself or to a super class/trait. Not sure what's more correct.
          Hide
          Nils added a comment -

          Just ran into this. Doesn't appear to have been backported to 2.9 against which it was filed.

          Show
          Nils added a comment - Just ran into this. Doesn't appear to have been backported to 2.9 against which it was filed.

            People

            • Assignee:
              Aleksandar Prokopec
              Reporter:
              david hall
            • Votes:
              4 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development