How can I elegantly serialize a lambda?
For example, the code below throws a NotSerializableException
. How can I fix it without creating a Seriali
If you are willing to switch to another serialization framework like Kryo, you can get rid of the multiple bounds or the requirement that the implemented interface must implement Serializable
. The approach is to
InnerClassLambdaMetafactory
to always generate the code required for serializationLambdaMetaFactory
during deserializationFor details and code see this blog post