Functional interfaces in Java 8

An abstract class (even if it only has one abstract method) is not a functional interface. Only an interface can be one.

From JLS 9.8:

A functional interface is an interface that has just one abstract method (aside from the methods of Object)... (emphasis added)

The original idea was to let abstact classes be expressed as a lambda; they were called "SAM types," which stood for "single abstract method." That turned out to be a difficult problem to solve efficiently. This thread talks a bit about why; basically, the base class's constructor made it difficult.


A function interface can have only ONE abstract method (besides the methods from Object class).

Source code for Gauge.java= http://grepcode.com/file/repo1.maven.org/maven2/com.codahale.metrics/metrics-core/3.0.0/com/codahale/metrics/Gauge.java#Gauge

Source code for RatioGauge.java= http://grepcode.com/file/repo1.maven.org/maven2/com.codahale.metrics/metrics-core/3.0.0/com/codahale/metrics/RatioGauge.java

Notice that Gauge.java only has one abstract method while RatioGauge has many methods.