code: private static SerializedLambda serializedLambda( Serializable lambda )
      {
          try
          {
              Method replaceMethod = lambda.getClass().getDeclaredMethod( "writeReplace" );
              replaceMethod.setAccessible( true );
              return (SerializedLambda) replaceMethod.invoke( lambda );
          }
          catch ( Exception e )
          {
              throw new IllegalStateException( "Reflection failed." );
          }
      }
docs: Serialize a ({@linkplain Serializable serializable}) lambda.
  
  @param lambda the ({@linkplain Serializable serializable}) lambda to serialize.
  @return the serialized form of the given lambda.