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
Add support for sending lambdas #12
Comments
Sending Java 8 lambdas to remote machines is not officially supported yet. At the moment Mobility-RPC targets Java 6 and later, but some newer language features are not guaranteed to work. I'm going to rename this issue to Add support for sending lambdas, as I want to add support for this. |
Hi, I have in the past investigated serialization of lambdas. It basically works out of the box if Java serialization is used and the interface that the lambda is implementing is serializable. So the probable solution to this is to allow the user of Java serialization instead of Kryo. |
The other solution is to enable lambda serialization in Kryo: https://github.com/magro/kryo/blob/bf803974ba6351d993093636aac00245f1ec28bc/test/com/esotericsoftware/kryo/serializers/Java8ClosureSerializerTest.java#L52 |
I'm not too concerned about Java 6 compatibility anymore. And I think Java 8 lambdas are quite a natural way to send tasks to remote machines. @BrynCooke I like the second option, to enable Java 8 closure support in Kryo. If you have time to try that out by modifying the KryoSerializer class in mobility-rpc and testing locally, it would help. I'm totally open to merging pull requests which would help with this! The main challenge I can envisage is that currently the mobility-rpc protocol supports sending only Runnable or Callable objects. Any other type of object to be sent (including lambdas) need to be wrapped in one of these. So the easiest solution if we want to send a lambda, is to write a helper method which wraps the lambda in a Runnable or Callable object. If this is possible then it should not be a problem to send a lambda. |
Thanks, I'll create a PR. |
Triggers exception message on the server:
However, if a formal inheritance class is made like the test code in #11, then the error is gone.
The text was updated successfully, but these errors were encountered: