{"action":"created","issue":{"url":"https://api.github.com/repos/romix/akka-kryo-serialization/issues/25","repository_url":"https://api.github.com/repos/romix/akka-kryo-serialization","labels_url":"https://api.github.com/repos/romix/akka-kryo-serialization/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/romix/akka-kryo-serialization/issues/25/comments","events_url":"https://api.github.com/repos/romix/akka-kryo-serialization/issues/25/events","html_url":"https://github.com/romix/akka-kryo-serialization/issues/25","id":30945573,"number":25,"title":"can register \"scala.collection.immutable.Map$Map1\"","user":{"login":"nefilim","id":992282,"avatar_url":"https://avatars.githubusercontent.com/u/992282?v=3","gravatar_id":"","url":"https://api.github.com/users/nefilim","html_url":"https://github.com/nefilim","followers_url":"https://api.github.com/users/nefilim/followers","following_url":"https://api.github.com/users/nefilim/following{/other_user}","gists_url":"https://api.github.com/users/nefilim/gists{/gist_id}","starred_url":"https://api.github.com/users/nefilim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nefilim/subscriptions","organizations_url":"https://api.github.com/users/nefilim/orgs","repos_url":"https://api.github.com/users/nefilim/repos","events_url":"https://api.github.com/users/nefilim/events{/privacy}","received_events_url":"https://api.github.com/users/nefilim/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2014-04-06T20:15:38Z","updated_at":"2016-07-11T18:05:34Z","closed_at":null,"body":"Implicitly registered class with id: scala.collection.immutable.Map$Map1=1962562276\r\n\r\nThis happens when I have a \r\n\r\n```scala \r\ncase class Stuff(map: Map[String, Map[String, String]]) \r\n```\r\n\r\nand try to serialize a literal like:\r\n\r\n```scala\r\nStuff(\r\n   Map(\"group1\" -> Map((\"key1\" -> \"value1\")))\r\n)\r\n```\r\n\r\nI've tried everything I could think of including:\r\n\r\n    kryo.register(Map.empty[String, Map[String, String]].getClass)\r\n    kryo.register(Map[String, Map[String, String]]().getClass)\r\n    kryo.register(Map.getClass)\r\n    kryo.register(classOf[scala.collection.immutable.Map[_, _]])\r\n    kryo.register(classOf[scala.collection.immutable.DefaultMap[_, _]])\r\n\r\nwith no luck :( \r\n"},"comment":{"url":"https://api.github.com/repos/romix/akka-kryo-serialization/issues/comments/231815674","html_url":"https://github.com/romix/akka-kryo-serialization/issues/25#issuecomment-231815674","issue_url":"https://api.github.com/repos/romix/akka-kryo-serialization/issues/25","id":231815674,"user":{"login":"jducoeur","id":2184929,"avatar_url":"https://avatars.githubusercontent.com/u/2184929?v=3","gravatar_id":"","url":"https://api.github.com/users/jducoeur","html_url":"https://github.com/jducoeur","followers_url":"https://api.github.com/users/jducoeur/followers","following_url":"https://api.github.com/users/jducoeur/following{/other_user}","gists_url":"https://api.github.com/users/jducoeur/gists{/gist_id}","starred_url":"https://api.github.com/users/jducoeur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jducoeur/subscriptions","organizations_url":"https://api.github.com/users/jducoeur/orgs","repos_url":"https://api.github.com/users/jducoeur/repos","events_url":"https://api.github.com/users/jducoeur/events{/privacy}","received_events_url":"https://api.github.com/users/jducoeur/received_events","type":"User","site_admin":false},"created_at":"2016-07-11T18:05:34Z","updated_at":"2016-07-11T18:05:34Z","body":"Don't have a self-contained test case (the relevant code isn't even on GitHub yet), but I'm hitting a variant of this same problem.  My Akka Persisted entity has:\r\n```\r\nprivate var fullShards = Set[ShardId](0, 1, 2, 3)\r\n```\r\nI'm persisting it in this message:\r\n```\r\ncase class ShardSnapshot(@KryoTag(1) fullShards:Set[ShardId], @KryoTag(2) shardAssignments:Map[ActorPath, ShardId]) extends UseKryo\r\n```\r\nIt turns out that the literal `Set` winds up getting instantiated in Scala as `scala.collection.immutable.Set.Set4`, a special optimized version of `Set` that is contained in its companion.  So it isn't actually implemented as a HashSet, it's this special little thing, which apparently has to be separately registered.\r\n\r\nI'm going to try working around it by declaring the object to be explicitly a HashSet (which will hopefully allow me to just register HashSet), but I'm still trying to puzzle out if there's a better way to do this.  \r\n\r\nAm I correct that Kryo has no concept of \"use this registration for all subclasses of T\"?  If so, then this is going to be an ongoing gotcha, I think -- there are a *lot* of subtle hidden subclasses lurking in the collections library.  Indeed, what I'm most concerned about is that `Set` and `Map` both have \"empty\" variants that are entirely private -- so I'm sure it's even *possible* to register them..."}}
{"actor":{"display_login":"jducoeur"}}