Java 6 Source向后兼容性和SQL [英] Java 6 Source backward-compatibility and SQL

查看:164
本文介绍了Java 6 Source向后兼容性和SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理解是,为了保持源兼容性,Java从不向公共接口引入新方法,因为这会破坏实现接口的现有客户端。 Java发行说明说明

My understanding is that in order to maintain source-compatibility, Java never introduces new methods to public interfaces, as that breaks existing clients implementing the interfaces. Java Release notes states


一般来说,保单如下,
除了以下进一步列出的任何不兼容性

In general, the policy is as follows, except for any incompatibilities listed further below:


  • 维护版本(例如1.4.1,
    1.4.2)不会引入任何新的语言功能或API。他们将
    保持与
    彼此的源兼容性。

  • Maintenance releases (such as 1.4.1, 1.4.2) do not introduce any new language features or APIs. They will maintain source-compatibility with each other.

功能发布和主要
版本(例如1.3。 0,1.4.0,5.0)
维持向上但不向下
源兼容性。

Functionality releases and major releases (such as 1.3.0, 1.4.0, 5.0) maintain upwards but not downwards source-compatibility.

然而,包 java.sql javax.sql 继续发展并介绍了许多不兼容的变化。例如,我注意到以下不兼容的更改(在Java 6中引入):

Yet, the packages java.sql and javax.sql continue to evolve and introduce many incompatible changes. For example, I noticed the following incompatible changes (introduced in Java 6):

  • java.sql.Statement extends java.sql.Wrapper, requiring new two new methods.
  • java.sql.Statement introduces 3 new methods
  • java.sql.PreparedStatement introduces 19 new methods!
  • java.sql.ResultSet introduces 48 new methods!

您知道这些方法的添加方法和原因吗? java.sql 与平台的其他部分区别对待吗?你知道关于这些新增内容的讨论/ JSR吗?

Do you know how and why these methods got added? Is java.sql being treated differently from the rest of the platform? Do you know of the discussion/JSR around these additions?

推荐答案

我收到了Sun开发人员的以下回复

JDK中用于JDK 7等功能发布的API的一般演变策略是

The general evolution policy for APIs in the JDK for feature releases like JDK 7 is


  1. 不破坏二进制兼容性(如JLSv3第13章中所定义)

  2. 避免引入源不兼容性

  3. 管理行为兼容性更改

(有关更多信息,请阅读

(For more, much more than you'd like to read on different kinds of compatibility see

兼容性:来源,二元和行为

兼容不断发展的BigDecimal

向接口添加方法是二进制兼容但是 source 不兼容,因此通常不会这样做。通常,接口越广泛实现,我们向其添加方法的可能性就越小。 JDBC区域是此策略的一个例外,它使用更宽松的升级规则,但当人们想要升级到新的JDK版本时,这确实会引起真正的问题。

Adding methods to interfaces is binary compatible but source incompatible, so it is not commonly done. Generally, the more widely implemented an interface is, the less likely we are to add methods to it. The JDBC area is an exception to this policy and uses looser upgrade rules, but that does cause real issues when people want to upgrade to a new JDK release.

这篇关于Java 6 Source向后兼容性和SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆