Defining the Set of FunctionalInterfaces

Brian Goetz brian.goetz at oracle.com
Thu Jul 4 08:16:06 PDT 2013


> 1. The only 'Listener-style' class annotated with @FunctionalInterface
> are java.util.prefs.PreferenceChangeListener and
> Thread.UncaughtExceptionHandler.
> I tend to think that all single-method Listener interface match the
> intention of a functional interface, an obvious example being
> java.beans.PropertyChangeListener and many of the java.awt EventListeners.

The lambda team did such a review of SAMs for most of core libraries, 
but we asked the Swing team to do this for this part of the JDK.  If 
someone in the community with more expertise in AWT/Swing would like to 
propose such a list, we'd be happy for that.

> 2. java.util.Comparable is annotated with @FunctionalInterface.
> This seems wrong to me. While technically being a functional interface,
> it cannot be used a a stateless function. Rather, it always has to be
> implemented by data-bearing classes.
> I cannot think of a reason to encourage conversion of lambda expressions
> to stand-alone java.util.Comparables.
>
> 3. java.io.Closeable is annotated with @FunctionalInterface.This is
> similar to java.util.Comparable:
> Stateful classes usually implement java.util.Closeable as a 'trait'.
> Stand-alone Closeables created from lambda expressions will be extremly
> rare.
>
> 4. java.util.concurrent.Callable is not annotated with
> @FunctionalInterface, even though it is certainly being used as a function.

Good feedback, will bring to EG.



More information about the lambda-libs-spec-observers mailing list