== Why is this an issue?

A Single Abstract Method (SAM) interface is a Java interface containing only one method. The Java API is full of SAM interfaces, such as ``++java.lang.Runnable++``, ``++java.awt.event.ActionListener++``, ``++java.util.Comparator++`` and ``++java.util.concurrent.Callable++``. SAM interfaces have a special place in Java 8 because they can be implemented using Lambda expressions or Method references. 


Using ``++@FunctionalInterface++`` forces a compile break when an additional, non-overriding abstract method is added to a SAM, which would break the use of Lambda implementations.


*Note* that this rule is automatically disabled when the project's ``++sonar.java.source++`` is lower than ``++8++``.


=== Noncompliant code example

[source,java]
----
public interface Changeable<T> {
  public void change(T o);
}
----


=== Compliant solution

[source,java]
----
@FunctionalInterface
public interface Changeable<T> {
  public void change(T o);
}
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Annotate the "XXXX" interface with the "@FunctionalInterface" annotation.  [(sonar.java.source not set. Assuming 8 or greater.)]


'''
== Comments And Links
(visible only on this page)

=== on 25 Feb 2014, 23:31:07 Freddy Mallet wrote:
Is implemented by \http://jira.codehaus.org/browse/SONARJAVA-462

=== on 26 Feb 2014, 01:50:25 Ann Campbell wrote:
I expanded a little here. Double-check me, please.

=== on 23 Oct 2015, 13:25:55 Michael Gumowski wrote:
\[~ann.campbell.2] I activated the rule by default, as we are now able to execute it only if the java version of the source code is java8+!

I also added code tags into the description.

=== on 19 Nov 2015, 17:25:40 Michael Gumowski wrote:
Fixed typo in error message (see commit: \https://github.com/SonarSource/sonar-java/commit/ef867a2aa66d071227bb00c2449cef2cceb8a738)

endif::env-github,rspecator-view[]
