default methods in interfaces
Brian Goetz
brian.goetz at oracle.com
Tue Oct 29 09:02:35 PDT 2013
Yes, see:
https://bugs.openjdk.java.net/browse/JDK-8022658
On 10/29/2013 11:40 AM, Gernot Neppert wrote:
> 2013/10/29 Paul Sandoz <paul.sandoz at oracle.com>
>
>>
>>
>> In terms of patterns for this kind of usage, i don't have a clear answer.
>> I expect some may evolve over time as developers evolve and implement new
>> interfaces that provide certain mix-in behaviour. Note that we have been
>> careful not to add the @FunctionalInteface annotation to all interfaces
>> that could be used as the target type of lambda expressions and method
>> references. In certain cases such non-annotated interfaces are more
>> intended to provide mix-in behaviour, so there is clue where to look and
>> watch.
>>
>>
> I'd like to know whether the proposals that I made (see
>
> http://mail.openjdk.java.net/pipermail/lambda-libs-spec-observers/2013-July/002288.html
> )
>
> have been considered? The latest snapshot looks unchanged in this respect,
> so I'll just re-post the observations that I made in July. I'm really
> curious whether any of the proposals below have been considered and why
> they have been rejected:
>
> 1. The only 'Listener-style' classes 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.
>
> 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!
>
More information about the lambda-dev
mailing list