I have the below code, which throws a NotSerializableException when I try to serialize the lambda.
public static void main(String[] args) throws Exception {
    File myFile = Files.createTempFile("lambda", "ser").toFile();
    try (ObjectOutput oo = new ObjectOutputStream(new FileOutputStream(myFile))) {
        Runnable r = () -> System.out.println("Can I be serialized?");
        oo.writeObject(r);
    }
    try (ObjectInput oi = new ObjectInputStream(new FileInputStream(myFile))) {
        Runnable  r = (Runnable) oi.readObject();
        r.run();
    }
}
I don't want to create a SerializableRunnable "dummy" interface for this. Please help!