A new feature included in JDK 8 allows you to add to an existing interface while maintaining binary compatibility.
The syntax is similar to
public interface SomeInterface() { void existingInterface(); void newInterface() default SomeClass.defaultImplementation; }
Thus, for all existing SomeInterface implementations SomeInterface when upgrading to this new version, not all of them suddenly compile errors around newInterface() .
While this is neat, what happens when you implement two interfaces that both added a new default method that you did not implement? Let me explain with an example.
public interface Attendance { boolean present() default DefaultAttendance.present; } public interface Timeline { boolean present() default DefaultTimeline.present; } public class TimeTravelingStudent implements Attendance, Timeline { }
Was this defined as part of JDK 8?
I found Java gods talking about something similar here http://cs.oswego.edu/pipermail/lambda-lib/2011-February/000068.html , but its part of a personal mailing list, and I cannot directly request them .
For more information about the default usage in JDK 8 and the extension of the Collection interface to support lambdas, see this section. https://oracleus.wingateweb.com/published/oracleus2011/sessions/25066/25066_Cho223662.pdf
java closures java-8 interface multiple-inheritance
Pyrolistical Oct 22 '11 at 6:25 2011-10-22 06:25
source share