JDK 8 code review request for 8005298 Add FunctionalInterface type to the core libraries

Joe Darcy joe.darcy at oracle.com
Wed Jan 16 16:58:09 UTC 2013


On 1/16/2013 8:32 AM, Florian Weimer wrote:
> On 01/16/2013 05:27 PM, Brian Goetz wrote:
>
>> The primary purpose of this annotation is to *capture design 
>> intent*.  It is not required.  The compiler will help you enforce the 
>> design intent if you provide it.  The compiler will not synthesize 
>> this annotation, since that would be guessing at the design intent.  
>> It is possible to create classfiles that subvert the design intent.
>>
>> The point about other languages was simply to point out that the 
>> universe of tools that might usefully use this design intent is 
>> bigger than sometimes assumed.
>
> I don't think run-time behavior should depend on optional annotations 
> documenting design intent (like @Override).
>
> Supporting the discovery of functional interfaces is a good idea. But 
> a method like Class#isFunctionalInterface() would sever this purpose 
> better than an entirely optional annotation.
>

A method like Class#isFunctionalInterface is planned too for later in JDK 8.

-Joe



More information about the core-libs-dev mailing list