Do you have a list of Java 8 Functional interfaces (not the ones listed in java.util.function)?

There is a list of all interfaces being annotated with @FunctionalInterface available in the API documentation, when you browse to the FunctionalInterface’s class documentation and click on the USE link at the top.

But it must be emphasized that the presence of the annotation is not mandatory to make an interface a functional interface. Each interface having exactly one abstract method not matching a public method of java.lang.Object can be implemented via lambda expressions or method references, though that doesn’t necessarily implies that the result will fulfill the additional contracts specified for the particular interface.

There are roughly 200 interfaces in the JRE fulfilling the technical constraints, so the compiler wouldn’t object when you try to implement them via lambda expression. Only a few of them have the annotation. Some of those not having the annotation will still work smoothly, e.g. ActionListener, InvocationHandler, or ThreadFactory, whereas others are unsuitable due to additional constraints like Comparable, ProtocolFamily, FlavorException. This is also discussed in “Why isn't @FunctionalInterface used on all the interfaces in the JDK that qualify?”

So while @FunctionalInterface documents the intention of being usable as target type of a lambda expression or method reference, other interface types may still be suitable for the same purpose, but you have to investigate the contracts yourself to conclude whether the use is appropriate.


Using @GhostCat's Eclipse method, here's the actual list of interfaces marked as @FunctionalInterface in the runtime library, excluding java.util.function.*:

java.awt.KeyEventDispatcher
java.awt.KeyEventPostProcessor
java.io.FileFilter
java.io.FilnameFilter
java.lang.Runnable
java.lang.Thread.UncaughtExceptionHandler
java.nio.file.DirectoryStream.Filter
java.nio.file.PathMatcher
java.time.temporal.TemporalAdjuster
java.time.temporal.TemporalQuery
java.util.Comparator
java.util.concurrent.Callable
java.util.logging.Filter
java.util.prefs.PreferenceChangeListener
jdk.management.resource.ResourceApprover
jdk.management.resource.ResourceId

Workaround: you might be able to use eclipse for example to gather such a list.

Simply jump into the source of that annotation and then search globally for its usage.

Alternatively you could use reflection and write code to scan all classes in some JAR to check each class if it is using that annotation. That would require some effort, but I don't see any major obstacles getting there; it's just about sitting down and doing it.

But of course, the real answer might be: this is probably a xy problem; and we should rather focus on the "why" you think you need to know about this.