Do Java 8 default methods break source compatibility?

后端 未结 5 1233
日久生厌
日久生厌 2020-11-30 05:24

It has generally been the case the Java source code has been forward compatible. Until Java 8, as far as I know, both compiled classes and source have been forward

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 05:57

    Ironically default methods in interfaces were introduced to allow existing libraries using those interfaces not to break, while introducing massive new functionality in the interfaces. (backward compatibility.)

    Conflicts like that sort method might arise. Something to pay for the extra functionality. In your case also something to investigate (should new functionality be used instead?).

    Java forward compatibility breaks are little, more in its typing system, which was constantly enlarged. First with generic types and now with inferred types from functional interfaces. From version to version and from compiler to compiler there were slight differences.

提交回复
热议问题