JDK 8 RFR for JDK-8022658: Revisit FunctionalInterface on some core libs types

Remi Forax forax at univ-mlv.fr
Mon Oct 21 21:29:37 UTC 2013


On 10/21/2013 08:16 PM, Joe Darcy wrote:
> Hello,
>
> Earlier in JDK 8, various core library classes were annotated with the 
> @FunctionalInterface annotation (JDK-8005623 Retrofit 
> FunctionalInterface annotations to core platform interfaces). As 
> experience has been gained with the feature, the time has come to 
> revisit some of those annotations under issue
>
>     JDK-8022658: Revisit FunctionalInterface on some core libs types
>
> In brief, I propose removing @FunctionalInterface from the following 
> six types:
>
>  src/share/classes/java/io/Closeable.java
>  src/share/classes/java/io/Flushable.java
>  src/share/classes/java/lang/AutoCloseable.java
>  src/share/classes/java/lang/Comparable.java
>  src/share/classes/java/lang/Iterable.java
>  src/share/classes/java/lang/Readable.java
>
> In these cases, the single method of the interface is more so a 
> mix-in/trait like feature and not readily usable standalone in a 
> lambda expression. Patch below.
>
> Thanks,
>
> -Joe

As a design note, the real way to avoid lambda conversion is to replace 
the abstract method by a default method that
throws a runtime exception.
I don't propose to do that here :)

cheers,
Rémi




More information about the core-libs-dev mailing list