Request for review: proposal for @FunctionalInterface checking
Joe Darcy
joe.darcy at oracle.com
Tue Jan 8 14:09:55 PST 2013
Hello Ali,
Use of @FunctionalInterface is optional and is just done to allow
stricter compile-time checking. If a functional interface is *not*
annotated with @FunctionalInterface, it can still be used for lambda
expressions, etc.
Cheers,
-Joe
On 01/08/2013 02:07 PM, Ali Ebrahimi wrote:
> Hi joe,
>
> does this mean if functional interfaces do not be annotated with
> @FunctionalInterface annotation can not be used in lambda expressions.
>
> general question: annotating of functional interfaces is required or
> optional?
> I ask this for this purpose that there is huge number of functional
> interfaces in java legacy third parties code base that all are
> candidate for use in lambda expressions and can not be retrofired to
> annotated with this annotation.
>
> Ali
>
> On Wed, Jan 9, 2013 at 12:34 AM, Joe Darcy <joe.darcy at oracle.com
> <mailto:joe.darcy at oracle.com>> wrote:
>
> Hello,
>
> While there were some reservations expressed about this proposal,
> there were no strong objections so I'm going forward with adding
> this annotation type to the platform, with a somewhat refined
> specification.
>
> Thanks,
>
> -Joe
>
>
> On 12/28/2012 1:38 PM, Joe Darcy wrote:
>
> Hi Sam,
>
> On 12/28/2012 12:28 PM, Sam Pullara wrote:
>
> On Dec 28, 2012, at 3:02 PM, Joe Darcy
> <joe.darcy at oracle.com <mailto:joe.darcy at oracle.com>
> <mailto:joe.darcy at oracle.com
> <mailto:joe.darcy at oracle.com>>> wrote:
>
> has exactly one abstract method. Since default
> methods are not abstract, any default methods declared
> in an interface do not contribute to its abstract
> method count. If an interface declares a method
> overriding one of the public methods of
> java.lang.Object, that also does <em>not</em> count
> toward the abstract method count.
>
>
> This is pretty murky. This works:
>
> interface Foo {
> @Override
> boolean equals(Object other);
> }
>
> but if you try this
>
> interface Foo {
> @Override
> default boolean equals(Object other) {
> return false;
> }
> }
>
> it does give an error that says I can't override:
>
> *java: default method equals in interface spullara.Foo
> overrides a member of java.lang.Object*
>
> Seems like "override" is the wrong word to use and will
> likely be confusing since we are explicitly disallowing
> the second one.
>
>
>
> Yes, I was contemplating whether "override" was the best
> phrasing to use in the wording above because of this sort of
> wrinkle. Instead "*abstract* method overriding one of the ..."
> might help distinguish this particular case.
>
> -Joe
>
>
>
More information about the lambda-libs-spec-observers
mailing list