I have a method to serialize a java map Map<UUID,String>
. It works fine. I can serialize and deserialize in java.
But I have to call this method from scala and this is my calling code.
def customSerialize:Unit = {
Serializer.serialize(modMap(scalaMap))
def modMap(oldMap : Map[UUID,SomeObject]) : java.util.Map[UUID,java.lang.String] = {
oldMap map { case(k,v) => (k->v.name)}
}
The scala map is scala.collection.Map
and I am using import scala.collection.JavaConversions._
for doing the conversion.
When I run this code I get the error
java.io.NotSerializableException: scala.collection.JavaConversions$MapWrapper
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
It looks like I need one more conversion from javaconversions$MapWrapper
to java.util.Map
. Is this correct? Is there a way to do this?