About FunctionalInterface Annotation

Vitaly Davidovich vitalyd at gmail.com
Thu Sep 19 06:49:42 PDT 2013


There should not be a runtime error since adding methods to an interface is
binary compatible. You will get compilation error though if you recompile
against the new A.

Sent from my phone
On Sep 19, 2013 3:42 AM, "Kaan Yamanyar" <kaan at yamanyar.com> wrote:

> Hi,
>
> According to javadoc of FunctionalInterface the compiler will treat any
> interface meeting the definition of a functional interface as a functional
> interface regardless of whether or not a FunctionalInterface annotation is
> present on the interface declaration.
>
> Let's assume there are two libraries (jar) I am using as a developer : A,B.
>
> Library "A" has an interface without the annotation and library "B" makes
> use of this interface using it as a functional interface.
>
> Meanwhile I upgraded version of library "A" due to some new features I need
> and let's assume that developers of "A" added one more method to interface
> which "B" was using as functional interface.
>
> Now I am going to have runtime exceptions from library "B" due to fact that
> the functional interface it assumes is not a functional interface any more.
>
> Should we accept that all developers writing an interface knows the usage
> of "functional interface" and accept this problem?
>
> Wouldn't it be discouraging for developers to use method referencing?
>
> Or am I totally misunderstood the issue :)?
>
> Regards,
> Kaan Yamanyar
>
> --
> *Saygılarımla,*
> *Kaan Yamanyar*
>
> kaan at yamanyar.com
> www.yamanyar.com
>
>


More information about the lambda-dev mailing list