== Why is this an issue?

With Java 8's "default method" feature, any abstract class without direct or inherited field should be converted into an interface. However, this change may not be appropriate in libraries or other applications where the class is intended to be used as an API.


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


=== Noncompliant code example

[source,java]
----
public abstract class Car {
  public abstract void start(Environment c);

  public void stop(Environment c) {
    c.freeze(this);
  }
}
----


=== Compliant solution

[source,java]
----
public interface Car {
  public void start(Environment c);

  public default void stop(Environment c) {
    c.freeze(this);
  }
}
----


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

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

=== Message

Convert the abstract class "XXXX" into an interface.  [(sonar.java.source not set. Assuming 8 or greater.)]


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

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

=== on 23 Oct 2015, 13:32:58 Michael Gumowski wrote:
Activated by default in java plugin 3.7, as the check will now only perform the analysis if java8 is detected for the sources.

=== on 14 Dec 2015, 11:53:41 Florian Schneider wrote:
Should this rule be modified to accept abstract classes with package private visibility that only contain methods with package private visibility?


Refactoring the abstract class as required by the rule to an interface would make the method public API, which might be undesired in some cases.

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