Why doesn't Java 5+ API take advantage of covariant return types?

后端 未结 2 1710
野性不改
野性不改 2021-01-02 05:18

Since Java 5 we are allowed to have covariant return types. Why doesn\'t the Java API take advantage of this?

Take Graphics2D.create() for instance. Why

2条回答
  •  既然无缘
    2021-01-02 05:39

    That would break binary compatibility. Previously compiled classes cannot find the method with the new return type. JLS3 §13.4.15, §13.4.12

提交回复
热议问题