The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

ttrippany (1) [Avatar] Offline

In section 9.4 you give an example of a class that inherits from two interfaces with the same method signature. This works fine as long as one interface extends the other.

However if a class implements two interfaces that are not related from a hierarchical view, but both define the same default method signature, then the class that extends both interfaces will not compile.

It is conceivable that two library developers could decide to add default methods at different times using common signatures; in fact it is probable that this will happen in libraries that implement similar concepts such as math libraries. If you happen to be the sorry soul extending both interfaces you will be broken on update.

I understand why they did this, to prevent a library developer from replacing the behavior of existing classes. But it also has the possibility of completely breaking existing libraries.

This is a mixed bag. Wondering if the authors have any comments on the matter as I'm certain it was a concession for extending the JDK. Perhaps I am missing something.