What is the reason why “synchronized” is not allowed in Java 8 interface methods?

In Java 8, I can easily write: interface Interface1 { default void method1() { synchronized (this) { // Something } } static void method2() { synchronized (Interface1.class) { // Something } } } I will get the full synchronisation semantics that I can use also in classes. I cannot, however, use the synchronized modifier on … Read more

Why is “final” not allowed in Java 8 interface methods?

One of the most useful features of Java 8 are the new default methods on interfaces. There are essentially two reasons (there may be others) why they have been introduced: Providing actual default implementations. Example: Iterator.remove() Allowing for JDK API evolution. Example: Iterable.forEach() From an API designer’s perspective, I would have liked to be able … Read more