Is it a feature abuse to introduce default methods in new interfaces?
jai.forums2013 at gmail.com
Thu Feb 21 14:35:25 UTC 2019
I have been trying to find some authoritative answer on when _not_ to
use default methods on interfaces (a feature introduced in Java 8). The
official documentation in Java, about this feature, talks about the
motivation behind introducing this feature and explains how
_existing_ interfaces can be changed to add default methods without
breaking binary compatibility:
"Default methods enable you to add new functionality to the interfaces
of your libraries and ensure binary compatibility with code written for
older versions of those interfaces."
This and some other docs don't mention whether it's an accepted practice
or abuse of default methods feature, when dealing with new interfaces.
Is it fine to introduce new interfaces with default methods? I have
tried searching the mailing list archives to see if it's discussed
previously but my search terms haven't found anything relevant. Any
previous authoritative answer, similar to Stuart Mark's reply on
stackoverflow (on a different topic) about Optional usage, is also
More information about the jdk-dev