JDK文档是语言规范的一部分吗? [英] Is the JDK documentation part of the language specification?

查看:206
本文介绍了JDK文档是语言规范的一部分吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只有一个官方 Java语言规范并且所有Java实现都必须遵守它。



API文档如何:所有Java实现都需要遵守这个版本或者实现是否可以以不同的方式定义某些方法和类的行为,只要它与JLS兼容? / p>

让我们举一个具体的例子:Java实现是否包含 HashMap ,它不接受 null 元素?

解决方案

我相信,是的,是的。



仔细检查后,我认为



As JLS 8声明在 p.1.4


1.4。与预定义类和接口的关系



如上所述,此规范通常是指Java
SE平台API的类。特别是,某些类与Java编程语言有特殊的
关系。示例包括
类,如Object,Class,ClassLoader,String,Thread,以及java.lang.reflect包中的
类和接口等。
此规范约束此类和
接口的行为,但不提供完整的规范。
读者可参考Java SE平台API文档。


从一方面他们状态,JLS文档未提供完整的规范并将读者发送到 Java SE平台API文档



另一方面,当提到Java SE的一些API(复数形式)时,JLS中有各种各样的地方。此外,似乎JLS不包含指向特定Java SE API规范的链接:


3.1。 Unicode



Java SE平台的一些API ,主要在Character类中,使用32位整数将代码点表示为单个实体。
Java SE平台提供了在16位和
32位表示之间进行转换的方法。



3.10.4。字符文字



字符文字只能代表UTF-16代码单元(§3.1),即
它们仅限于从\\\到\\\￿的值。补充
字符必须表示为
字符序列中的代理项对,或者表示为整数,取决于它们使用的API
with。



9.6.4。预定义的注释类型



在Java
SE平台的库中预定义了几种注释类型。其中一些预定义的注释类型具有特殊的
语义。这些语义在本节中指定。本节
未提供此处包含的预定义
注释的完整规范; 这是相应的
API规范的作用
。这里只指定那些在Java编译器或Java虚拟机
实现方面需要特殊
行为的语义。



There is only one official Java Language Specification and all Java implementations must comply with it.

How about the API documentation: do all Java implementations need to comply with this version or could an implementation define the behaviour of some methods and classes differently, as long as it's compatible with the JLS?

Let's throw a concrete example: could a Java implementation include a HashMap that doesn't accept null elements?

解决方案

I believe, that, yes it is.

Upon closer examination, I think it is not.

As JLS 8 states in p.1.4:

1.4. Relationship to Predefined Classes and Interfaces

As noted above, this specification often refers to classes of the Java SE platform API. In particular, some classes have a special relationship with the Java programming language. Examples include classes such as Object, Class, ClassLoader, String, Thread, and the classes and interfaces in package java.lang.reflect, among others. This specification constrains the behavior of such classes and interfaces, but does not provide a complete specification for them. The reader is referred to the Java SE platform API documentation.

From one hand they state, that JLS document does not provide a complete specification and send reader to the Java SE platform API documentation.

From other hand, there are various places in the JLS when some APIs (plural form) of Java SE are mentioned. Furthermore, it seems that JLS does not contain links to the particular Java SE API specification:

3.1. Unicode

Some APIs of the Java SE platform, primarily in the Character class, use 32-bit integers to represent code points as individual entities. The Java SE platform provides methods to convert between 16-bit and 32-bit representations.

3.10.4. Character Literals

Character literals can only represent UTF-16 code units (§3.1), i.e., they are limited to values from \u0000 to \uffff. Supplementary characters must be represented either as a surrogate pair within a char sequence, or as an integer, depending on the API they are used with.

9.6.4. Predefined Annotation Types

Several annotation types are predefined in the libraries of the Java SE platform. Some of these predefined annotation types have special semantics. These semantics are specified in this section. This section does not provide a complete specification for the predefined annotations contained here in; that is the role of the appropriate API specifications. Only those semantics that require special behavior on the part of a Java compiler or Java Virtual Machine implementation are specified here.

这篇关于JDK文档是语言规范的一部分吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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