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

Force Serialization of Lambdas #320

Open
magicwerk opened this issue Jan 5, 2022 · 2 comments
Open

Force Serialization of Lambdas #320

magicwerk opened this issue Jan 5, 2022 · 2 comments

Comments

@magicwerk
Copy link

magicwerk commented Jan 5, 2022

I try to use FST to serialize Java objects where not all contained instances are Serializable by using

FSTConfiguration.getDefaultConfiguration().setForceSerializable(true)

However this does not seem to work for classes containing lambdas:
java.lang.ClassNotFoundException: eval.fst.EvalFst$NoSerializableLambda$$Lambda$3/205962452

class NoSerializableLambda {
Predicate filter = (s) -> s.startsWith("a");
}

Is there a way to configure FST so also lambdas can be serialized?

@masmc05
Copy link

masmc05 commented Jun 22, 2022

try
Predicate<String> filter = (Predicate<String> & Serializable) (s) -> s.startsWith("a");
this will make the lambda serializable
idk if there are other solutions

@magicwerk
Copy link
Author

I'm aware of how lambdas can be made explicitly Serializable as shown, thanks.
The interesting part however would be whether FST somehow manages to serialize lambdas not defined as Serializable, as it manages to serialize classes not implementing Serialiazable.

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