Request for review: proposal for @FunctionalInterface checking
Joe Darcy
joe.darcy at oracle.com
Sat Dec 29 11:43:20 PST 2012
On 12/29/2012 10:04 AM, Gernot Neppert wrote:
> Am 29.12.2012 18:23, schrieb Joe Darcy:
>>
>>
>> Amongst others; we would systematically find and annotate such
>> interfaces in the JDK if the FunctionalInterface type is added. In
>> JDK 7, analagous efforts were undertaken for adding @SafeVarargs and
>> AutoCloseable:
>>
>
> Good that you bring it up: @SafeVarargs was a very clever idea because
> it actually conveyed some valualble additional information that could
> not be deduced otherwise from the class' or method's declaration:
> namely, that the *implementation* of a method will not access an array
> of a generic type in a way that could compromise type-safety.
> IMO, merely stating that an interface has one abstract method is not
> something that cannot be deduced otherwise.
>
>> That is not my assessment of the situation.
>>
>> If the interface is annotated with @FunctionalInterface that means
>> its future evolution should be constrained to not add, directly or
>> indirectly, new methods without defaults, including in superinterfaces.
>>
>
> IIRC, it was this very constraint that spurred the idea of having
> defaulted methods in the first place!
>
> So, if this policy is valid for all interfaces, it doesn't need to be
> explicitly emphasized for SAM interfaces, right?
We are well aware the @FunctionalInterface annotation is not strictly
necessary. However, in our estimation it would be a helpful addition to
the platform.
-Joe
More information about the lambda-libs-spec-observers
mailing list