FunctionalInterface as a rule in the matching interfaces ?
joe.darcy at oracle.com
Thu Aug 8 18:55:20 UTC 2013
On 8/1/2013 5:28 AM, Jean-Baptiste Bugeaud wrote:
> As a follow-up from Joe Darcy's proposal (2013-02-06) to add
> @FunctionalInterface to some interfaces matching the requirements of
> I propose that this improvement is applied to all the VM Java libs.
> Doing a quick search, I've found some interfaces are not tagged as
> FunctionaInterfaces but clearly look good candidates :
> Here is the list of public API I have found so far :
I found the candidate interfaces by running an annotation processor over
the JDK codebase:
A bug was filed for analogous API review in the swing area:
JDK-8007716 Add FunctionalInterface annotation to swing interfaces
and other client teams were contacted as well (2D team on Feb. 8, etc.),
but that work has not been done yet. Thanks for the reminder.
The general guidance given at the time was:
> To a first approximation, if a candidate type today is commonly
> created using anonymous inner classes, it is reasonable to add the
> functionalInterface annotation. Note that the compiler will allow any
> type meeting the structural requirements of a functional interface to
> be used in a lambda expression; the annotation just provides
> documentation of intent.
There are also a few core libs are interfaces where we may want to
re-examine if @FI is really needed.
More information about the core-libs-dev