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

Support serialized lambdas #35

Closed
Alexander-- opened this issue Sep 30, 2014 · 4 comments
Closed

Support serialized lambdas #35

Alexander-- opened this issue Sep 30, 2014 · 4 comments

Comments

@Alexander--
Copy link

My Android code always becomes a mess, because the only thing, that can be passed between call to startActivityForResult() and corresponding call to onActivityResult(), is an Intent (possibly with Bundle of Serializable stuff). The issue isn't just limited to calling external apps: a lot of interaction between components in Android, all kinds of in-process and interprocess communication as well as saving and restoring application state rely on passing Bundles of Serializable values between caller and recepient.

Serialized lambdas would let Android developers use lots of Intents without grinding code flow to halt and actually employ application state restoration, as opposite to just hoping, that application process won't be killed by system in background.

Regarding implementation: it would, probably, be better to change package name of SerializedLambda to something other than java.lang.invoke in event, that Java 8 language features are implemented by Android developers someday.

@luontola
Copy link
Owner

luontola commented Oct 3, 2014

Actually it might be possible to implement this without the equivalent of SerializedLambda, because we can (de)serialize the backported lambda classes without jumping through invokedynamic hooks. And anyways it's not possible to add user classes to the java.* packages, so the name would have to be different.

Serializing anonymous classes is an anti-pattern, because their names may change when the code is recompiled. Though I suppose that serializable lambdas may suffer from the same issue, so it should not be much worse.

I'll need to investigate this some more. It would be best if we can ignore the $deserializeLambda$ methods which SerializedLambda uses...

@luontola
Copy link
Owner

luontola commented Oct 3, 2014

BTW, in what way does Retrolambda currently fail for applications that use serializable lambdas?

@Alexander--
Copy link
Author

java.lang.NoClassDefFoundError: java.lang.invoke.SerializedLambda

@luontola
Copy link
Owner

This feature has now been included in Retrolambda 1.7.0. It doesn't require any runtime dependencies - the lambda classes are serialized the same way as anonymous inner classes (with the same caveats e.g. their name may change without warning between builds).

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

No branches or pull requests

2 participants