@FunctionalInterface and Javadoc
David Holmes
david.holmes at oracle.com
Mon Nov 25 16:53:47 PST 2013
On 26/11/2013 10:41 AM, Brian Goetz wrote:
> A long time ago, we agreed that the Javadoc for a functional interface
> should say something like "This is a functional interface." This is
> done using a structural analysis of the interface, just as when used as
> the target of a lambda.
>
> Later in time, we arrived at @FunctionalInterface, which is optional to
> use. It is closest in spirit to @Override, since:
> - It captures design intent
> - It enlists the compiler's aid in catching violations of such intent;
> an @FI-marked method that is not a functional interface will merit a
> compile error.
>
> It has recently been pointed out that perhaps we should adjust the
> Javadoc generation, to trigger off of @FI rather than structurally,
> since there are functional interfaces in the JDK that are not marked @FI
> (deliberately) but which still bear the "This is a functional interface"
> blurb.
I would think you still want both as discussed in the email thread, but
with different wording, also as discussed. I can imagine existing
libraries being used across 7 and 8 and so not being able to apply @FI.
I think something like:
"In its current form this is implicitly a functional interface."
which captures the implicit-ness and that in the future, should the
interface be enhanced, it may no longer be a functional interface.
David
More information about the lambda-spec-observers
mailing list