Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function does not implement Serializable #1424

Closed
gissuebot opened this issue Oct 31, 2014 · 4 comments
Closed

Function does not implement Serializable #1424

gissuebot opened this issue Oct 31, 2014 · 4 comments

Comments

@gissuebot
Copy link

Original issue created by rpvilao on 2013-05-23 at 02:24 PM


Hi all,

When you perform Lists.transform and pass a Function the result is a TransformingRandomAccessList that indeed is Serializable, but Function is also a member of this class and Function is not Serializable which makes the whole object not Serializable as well.

Is this a known issue?

@gissuebot
Copy link
Author

Original comment posted by wasserman.louis on 2013-05-24 at 06:17 AM


The solution here is to make your Function Serializable, since not all Functions are (or should be!) Serializable. (This may require an explicit named class, rather than an anonymous class, of course.)

@gissuebot
Copy link
Author

Original comment posted by rpvilao on 2013-05-24 at 09:00 AM


Hello,

Thank you for your comment. I just have a question... why isn't the function Serializable? 99% of the people using this library use an anonymous function and without any members, right? Am I missing something here?

From a user perspective I never expected that the function would be even stored in a member! What could be the harm in extending Serializable in the Function interface?

Cheers!

Rui

@gissuebot
Copy link
Author

Original comment posted by kevinb@google.com on 2013-05-24 at 02:24 PM


Never make abstract types Serializable! Serialization is fundamentally an implementation concern; each implementation needs to decide whether it wants to be serializable, and if it does, how it wants to be serializable (you cannot assume that default serialization is right for each case). If we make our interfaces serializable we can open security holes, not to mention that users who have all their javac warnings enabled will get a serialVersionUID warning on every single function in their entire codebase, which would be horrible.

If you find any actual Functions in our codebase that we return to you but did not make serializable, please report those.

In Java 8, serializable functions will be as easy as "transform((& Serializable) a -> a.b())". (Or at least I think that proposal carried... hmm.)


Status: WorkingAsIntended

@gissuebot
Copy link
Author

Original comment posted by rpvilao on 2013-05-24 at 02:26 PM


Fair enough :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant