{"action":"created","issue":{"url":"https://api.github.com/repos/immutables/immutables/issues/243","labels_url":"https://api.github.com/repos/immutables/immutables/issues/243/labels{/name}","comments_url":"https://api.github.com/repos/immutables/immutables/issues/243/comments","events_url":"https://api.github.com/repos/immutables/immutables/issues/243/events","html_url":"https://github.com/immutables/immutables/issues/243","id":128826287,"number":243,"title":"Problems with Optional fileds on Serializable values","user":{"login":"redvasily","id":79625,"avatar_url":"https://avatars.githubusercontent.com/u/79625?v=3","gravatar_id":"","url":"https://api.github.com/users/redvasily","html_url":"https://github.com/redvasily","followers_url":"https://api.github.com/users/redvasily/followers","following_url":"https://api.github.com/users/redvasily/following{/other_user}","gists_url":"https://api.github.com/users/redvasily/gists{/gist_id}","starred_url":"https://api.github.com/users/redvasily/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redvasily/subscriptions","organizations_url":"https://api.github.com/users/redvasily/orgs","repos_url":"https://api.github.com/users/redvasily/repos","events_url":"https://api.github.com/users/redvasily/events{/privacy}","received_events_url":"https://api.github.com/users/redvasily/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-26T13:53:13Z","updated_at":"2016-01-26T18:38:18Z","closed_at":"2016-01-26T13:56:02Z","body":"When using Serializable immutable value classes (implementing serializable interface), with java.util.Optional fields a generated Immutabe... class is not serializable as java.util.Optional is not serializable, and a generated class uses private java.util.Optional fields.\r\n\r\nSee this Stackoverflow answer: http://stackoverflow.com/questions/24547673/why-java-util-optional-is-not-serializable-how-to-serialize-the-object-with-suc\r\n\r\nLeading to this email: http://mail.openjdk.java.net/pipermail/jdk8-dev/2013-September/003273.html\r\n\r\nApparently java.util.Optional authors don't want it be serializable.\r\n\r\nPerhaps Immutables could generate regular (non-optional) fields and store null there if the value is not present, and return Optional.empty() if the value is not set. This would allow to keep interfaces use Optionals for optional fields in a public interface (which I think is very convenient), while the private implementation would become serializable.\r\n"},"comment":{"url":"https://api.github.com/repos/immutables/immutables/issues/comments/175164626","html_url":"https://github.com/immutables/immutables/issues/243#issuecomment-175164626","issue_url":"https://api.github.com/repos/immutables/immutables/issues/243","id":175164626,"user":{"login":"redvasily","id":79625,"avatar_url":"https://avatars.githubusercontent.com/u/79625?v=3","gravatar_id":"","url":"https://api.github.com/users/redvasily","html_url":"https://github.com/redvasily","followers_url":"https://api.github.com/users/redvasily/followers","following_url":"https://api.github.com/users/redvasily/following{/other_user}","gists_url":"https://api.github.com/users/redvasily/gists{/gist_id}","starred_url":"https://api.github.com/users/redvasily/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redvasily/subscriptions","organizations_url":"https://api.github.com/users/redvasily/orgs","repos_url":"https://api.github.com/users/redvasily/repos","events_url":"https://api.github.com/users/redvasily/events{/privacy}","received_events_url":"https://api.github.com/users/redvasily/received_events","type":"User","site_admin":false},"created_at":"2016-01-26T18:38:18Z","updated_at":"2016-01-26T18:38:18Z","body":"Sorry about that, I guess I made a typo when looking for \"Serializable\" in the issues so I didn't find #240, and noticed it only after I've already created the issue.\r\n\r\nI've switched to the snapshot version (\"2.1.9-SNAPSHOT\") and it's working fine so far for me."}}