Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am eshrubs on github.
  • I am eshr (https://keybase.io/eshr) on keybase.
  • I have a public key ASCwhHCMzCPnMLhLi7au35SMB-wCLh0hQY8XHmXLy4pNDwo

To claim this, I am signing this object:

@eshrubs
eshrubs / serialized.java
Created July 19, 2017 09:24
Convert Function<> to SerializedLambda
public interface Getter<A, T> extends Function<A, T>, Serializable {
}
private static SerializedLambda getSerialized(Getter<?, ?> getter) throws Exception {
requireNonNull(getter);
// There is a private method made by the compiler called ${writeReplace}
// that converts this lambda to a SerializedLambda.
// Expose that method and run it!
Method writeReplace = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
@Override