gpt4 book ai didi

java - JDK 文档是语言规范的一部分吗?

转载 作者:搜寻专家 更新时间:2023-11-01 02:58:44 29 4
gpt4 key购买 nike

官方只有一个Java Language Specification并且所有 Java 实现都必须遵守它。

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

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

最佳答案

我相信,是的。

经过仔细检查,我认为不是

正如 JLS 8 在 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.

一方面,他们声明 JLS 文档没有提供完整的规范,并将读者发送到 Java SE 平台 API 文档

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

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.

关于java - JDK 文档是语言规范的一部分吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43629354/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com