Skip to content

Instantly share code, notes, and snippets.

@okram
Created January 22, 2014 20:47
Show Gist options
  • Save okram/8567081 to your computer and use it in GitHub Desktop.
Save okram/8567081 to your computer and use it in GitHub Desktop.
@Test
public void shouldSerializeLambda() throws Exception {
ByteArrayOutputStream outBytes = new ByteArrayOutputStream(10);
ObjectOutputStream out = new ObjectOutputStream(outBytes);
final SerializedPredicate predicate = e -> true;
out.writeObject(predicate);
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(outBytes.toByteArray()));
Predicate p = (Predicate) in.readObject();
assertTrue(p.test(null));
}
public interface SerializedPredicate<T> extends Predicate<T>, Serializable {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment