The functional interface Function in Java 1.8 implements compose() as shown:
default <V> Function<V, R> compose(Function<? super V, ? extends T> before) {
Objects.requireNonNull(before);
return (V v) -> apply(before.apply(v));
}
My understanding of lambda expressions (possibly incorrect) is that the above return statement is syntactic sugar for:
return new Function<V, R>() {
R apply(V v) {
return apply(before.apply(v));
}};
This statement would be illegal because, as an interface, Function<V, R> should not be instantiable. So how does the above method work?