Platypus Header

Platypus Innovation Blog

13 October 2014

Java 8 introduces several nice features, one of which is the default keyword. This is close to having mix-ins (aka traits; inheriting code from multiple parents) which is great. It also lets you add new methods to an old interface without breaking existing implementations. Or that's what it's meant to do.

But Oracle have broken backwards compatibility.

It is an error for a class to inherit a default method from two parents. If that happens, then the class must override the default method to specify what happens.

But if the default method involves a Java 8 class, then implementing it will break your code for Java 7.

I encountered this because we have a class which implements both List and Set. It's now impossible to do that if your code has to work across Java 7 and 8. To work in Java 8, it has to implement spititerator(), but that will break Java 7 which knows nothing of the Splititerator class.

About

The platypus caused consternation, shattered existing categories. It's existence was undeniable, but how should taxonomic theory be adapted to accommodate this uncomfortable fact? This blog is also hard to classify. It loosely follows the professional interests and activities of Daniel Winterstein. Topics are likely to range from business affairs to new media via data science and abstract mathematics.