apemanzilla

java 10 fuckery

Mar 20th, 2018
102
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2.  
  3. class Fuckery {
  4.     public static void main(String[] args) throws IOException, ClassNotFoundException {
  5.         var lambda = (Runnable & Serializable)() -> System.out.println("Hi");
  6.  
  7.         var out = new ByteArrayOutputStream();
  8.         var oos = new ObjectOutputStream(out);
  9.         oos.writeObject(lambda);
  10.         oos.close();
  11.  
  12.         var in = new ObjectInputStream(new ByteArrayInputStream(out.toByteArray()));
  13.         var lambda2 = (Runnable) in.readObject();
  14.         in.close();
  15.  
  16.         lambda2.run();
  17.     }
  18. }
RAW Paste Data