JDK17Src-0.java.base

版本 17 API 规范

本文档分为两部分:
Java SE :Java 平台标准版 (Java SE) API 定义了用于通用计算的核心 Java 平台。这些 API 位于名称以java.
JDK:Java 开发工具包 (JDK) API 特定于 JDK,不一定在 Java SE 平台的所有实现中都可用。这些 API 位于名称以jdk.

java.base定义 Java SE 平台的基础 API。
java.compiler定义语言模型、注释处理和 Java 编译器 API。
java.datatransfer定义用于在应用程序之间和应用程序内部传输数据的 API。
java.desktop定义 AWT 和 Swing 用户界面工具包,以及用于辅助功能、音频、成像、打印和 JavaBeans 的 API。
java.instrument定义允许代理程序检测在 JVM 上运行的程序的服务。
java.logging定义 Java 日志记录 API。
java.management定义 Java 管理扩展 (JMX) API。 Java Management Extensions
java.management.rmi为 Java 管理扩展 (JMX) 远程 API 定义RMI 连接器。
java.naming定义 Java 命名和目录接口 (JNDI) API。 Java Naming and Directory Interface
java.net.http定义 HTTP 客户端和 WebSocket API。
java.prefs定义首选项 API。Defines the Preferences API.
java.rmi定义远程方法调用 (RMI) API。Remote Method Invocation
java.scripting定义脚本 API。
java.se定义 Java SE 平台的 API。
java.security.jgss定义 IETF 通用安全服务 API (GSS-API) 的 Java 绑定。Defines the Java binding of the IETF Generic Security Services API (GSS-API).
java.security.sasl定义对 IETF 简单身份验证和安全层 (SASL) 的 Java 支持。Defines Java support for the IETF Simple Authentication and Security Layer (SASL).
java.smartcardio定义 Java 智能卡 I/O API。
java.sql定义 JDBC API。
java.sql.rowset定义 JDBC 行集 API。
java.transaction.xa定义用于支持 JDBC 中分布式事务的 API。
java.xml定义用于 XML 处理的 Java API (JAXP)、用于 XML 的流式处理 API (StAX)、用于 XML 的简单 API (SAX) 和 W3C 文档对象模型 (DOM) API。Defines the Java API for XML Processing (JAXP), the Streaming API for XML (StAX), the Simple API for XML (SAX), and the W3C Document Object Model (DOM) API.
java.xml.crypto定义用于 XML 加密的 API。Defines the API for XML cryptography.
jdk.accessibility定义辅助技术实现者使用的 JDK 实用程序类。
jdk.attach定义附加 API。Defines the attach API.
jdk.charsets提供不在 java.base中的字符集(主要是双字节和 IBM 字符集)。
jdk.compiler定义了系统 Java 编译器及其命令行等效项javac的实现。
jdk.crypto.cryptoki提供 SunPKCS11 安全提供程序的实现。Provides the implementation of the SunPKCS11 security provider.
jdk.crypto.ec提供 SunEC 安全提供程序的实现。Provides the implementation of the SunEC security provider.
jdk.dynalink定义用于动态链接对象高级操作的 API。Defines the API for dynamic linking of high-level operations on objects.
jdk.editpad提供jdk.jshell使用的编辑板服务的实现。Provides the implementation of the edit pad service used by jdk.jshell.
jdk.hotspot.agent定义热点可维护性代理的实现。Defines the implementation of the HotSpot Serviceability Agent.
jdk.httpserver定义特定于 JDK 的 HTTP 服务器 API。Defines the JDK-specific HTTP server API.
jdk.incubator.foreign定义一个 API,用于直接从 Java 访问外部内存和调用外部函数。Defines an API for accessing foreign memory and calling foreign functions, directly from Java.
jdk.incubator.vector定义一个 API,用于表达可在运行时可靠地编译为 SIMD 指令的计算,例如 x64 上的 AVX 指令和 AArch64 上的 NEON 指令。
jdk.jartool定义用于操作 Java 归档 (JAR) 文件的工具,包括jar和jarsigner工具。Defines tools for manipulating Java Archive (JAR) files, including the jar and jarsigner tools.
jdk.javadoc定义了系统文档工具及其命令行等效项javadoc的实现。Defines the implementation of the system documentation tool and its command-line equivalent, javadoc.
jdk.jcmd定义用于诊断和排除JVM故障的工具,如jcmd,jps,jstat工具。Defines tools for diagnostics and troubleshooting a JVM such as the jcmd, jps, jstat tools.
jdk.jconsole定义 JMX 图形工具jconsole,用于监视和管理正在运行的应用程序。Defines the JMX graphical tool, jconsole, for monitoring and managing a running application.
jdk.jdeps定义用于分析 Java 库和程序中依赖关系的工具,包括jdeps、javap和 jdeprscan工具。Defines tools for analysing dependencies in Java libraries and programs, including the jdeps, javap, and jdeprscan tools.
jdk.jdi定义 Java 调试接口。
jdk.jdwp.agent提供 Java 调试连线协议 (JDWP) 代理的实现。Provides the implementation of the Java Debug Wire Protocol (JDWP) agent.
jdk.jfr定义 JDK 飞行记录器的 API。
jdk.jlink定义用于创建运行时映像的jlink工具、用于创建和操作JMOD文件的 jmod 工具,以及用于检查特定于 JDK 实现的容器文件中的类和资源的jimage工具。
jdk.jpackage定义 Java 打包工具 jpackage。
jdk.jshell提供用于评估 Java 代码片段的jshell工具,并定义特定于 JDK 的 API 用于建模和执行代码片段。
jdk.jsobject定义 JavaScript 对象的 API。
jdk.jstatd定义jstatd工具,用于启动 jstat 工具的守护程序以远程监视 JVM 统计信息。Defines the jstatd tool for starting a daemon for the jstat tool to monitor JVM statistics remotely.
jdk.localedata为美国区域设置 以外的区域设置提供区域设置数据。
jdk.management为 JVM 定义特定于 JDK 的管理接口。
jdk.management.agent定义 JMX 管理代理程序。
jdk.management.jfr定义 JDK 飞行记录仪的管理接口。
jdk.nameing.dns提供 DNS Java 命名提供程序的实现。
jdk.nameing.rmi提供 RMI Java 命名提供程序的实现。
jdk.net定义特定于 JDK 的网络 API。
jdk.nio.mapmode定义特定于 JDK 的文件映射模式。
jdk.sctp为 SCTP 定义特定于 JDK 的 API。
jdk.security.auth提供接口和各种身份验证模块的实现。javax.security.auth.* Provides implementations of the javax.security.auth.* interfaces and various authentication modules.
jdk.security.jgss定义对 GSS-API 的 JDK 扩展以及 SASL GSSAPI 机制的实现。Defines JDK extensions to the GSS-API and an implementation of the SASL GSSAPI mechanism.
jdk.xml.dom定义不属于 Java SE API 的 W3C 文档对象模型 (DOM) API 的子集。Defines the subset of the W3C Document Object Model (DOM) API that is not part of the Java SE API.
jdk.zipfs提供 Zip 文件系统提供程序的实现。
Provides the implementation of the Zip file system provider.

java.base

java.io通过数据流、序列化和文件系统提供系统输入和输出。Provides for system input and output through data streams, serialization and the file system.
java.lang提供对 Java 编程语言的设计至关重要的类。Provides for system input and output through data streams, serialization and the file system.
java.lang.annotation为 Java 编程语言注释工具提供库支持。
java.lang.constant类和接口,用于表示运行时实体(如类或方法句柄)和类文件实体(如常量池条目或invokedynamic调用站点)的名义描述符。Classes and interfaces to represent nominal descriptors for run-time entities such as classes or method handles, and classfile entities such as constant pool entries or invokedynamic call sites.
java.lang.invoke该java.lang.invoke包提供了用于与 Java 虚拟机交互的低级基元。
The java.lang.invoke package provides low-level primitives for interacting with the Java Virtual Machine.
java.lang.module用于支持模块描述符的类,并通过解析和服务绑定创建模块的配置。
java.lang.ref提供引用对象类,这些类支持与垃圾回收器的有限程度的交互。Provides reference-object classes, which support a limited degree of interaction with the garbage collector.
java.lang.reflect提供用于获取有关类和对象的反射信息的类和接口。Provides classes and interfaces for obtaining reflective information about classes and objects.
java.lang.runtime该java.lang.runtime包为 Java 语言提供低级运行时支持。The java.lang.runtime package provides low-level runtime support for the Java language.
java.math提供用于执行任意精度整数算术 (BigInteger) 和任意精度十进制算术 (BigDecimal) 的类。Provides classes for performing arbitrary-precision integer arithmetic (BigInteger) and arbitrary-precision decimal arithmetic (BigDecimal).
java.net提供用于实现网络应用程序的类。
java.net.spi java.net包的服务提供程序类。Service-provider classes for the java.net package.
java.nio定义缓冲区,这些缓冲区是数据的容器,并提供其他 NIO 包的概述。Defines buffers, which are containers for data, and provides an overview of the other NIO packages.
java.nio.channels定义通道,这些通道表示与能够执行 I/O 操作的实体(如文件和套接字)的连接;定义选择器,用于多路复用、非阻塞 I/O 操作。Defines channels, which represent connections to entities that are capable of performing I/O operations, such as files and sockets; defines selectors, for multiplexed, non-blocking I/O operations.
java.nio.channels.spi java.nio.channels包的服务提供程序类。
java.nio.charset定义字符集、解码器和编码器,用于在字节和 Unicode 字符之间进行转换。
java.nio.charset.spi java.nio.charset包的服务提供程序类。
java.nio.file为 Java 虚拟机定义接口和类,以访问文件、文件属性和文件系统。Defines interfaces and classes for the Java virtual machine to access files, file attributes, and file systems.
java.nio.file.attribute提供对文件和文件系统属性的访问的接口和类。Interfaces and classes providing access to file and file system attributes.
java.nio.file.spi java.nio.file包的服务提供程序类。Service-provider classes for the java.nio.file package.
java.security提供安全框架的类和接口。Provides the classes and interfaces for the security framework.
java.security.cert提供用于分析和管理证书、证书吊销列表 (CRL) 和证书路径的类和接口。Provides classes and interfaces for parsing and managing certificates, certificate revocation lists (CRLs), and certification paths.
java.security.interfaces提供用于生成 RSA 实验室技术说明 PKCS#1 中定义的 RSA(Rivest、Shamir 和 Adleman AsymmetricCipher 算法)密钥的接口,以及 NIST 的 FIPS-186 中定义的 DSA(数字签名算法)密钥。Provides interfaces for generating RSA (Rivest, Shamir and Adleman AsymmetricCipher algorithm) keys as defined in the RSA Laboratory Technical Note PKCS#1, and DSA (Digital Signature Algorithm) keys as defined in NIST's FIPS-186.
java.security.spec为关键规范和算法参数规范提供类和接口。Provides classes and interfaces for key specifications and algorithm parameter specifications.
java.text提供用于以独立于自然语言的方式处理文本、日期、数字和消息的类和接口。
java.text.spi java.text 包中类的服务提供程序类。Service provider classes for the classes in the java.text package.
java.time日期、时间、即时和持续时间的主 API。
The main API for dates, times, instants, and durations.
java.time.chrono 默认 ISO 以外的日历系统的通用 API。Generic API for calendar systems other than the default ISO.
java.time.format 提供用于打印和分析日期和时间的类。Provides classes to print and parse dates and times.
java.time.temporal 使用字段和单位以及日期时间调整器访问日期和时间。Access to date and time using fields and units, and date time adjusters.
java.time.zone 支持时区及其规则。
java.util 包含集合框架、一些国际化支持类、服务加载程序、属性、随机数生成、字符串分析和扫描类、base64 编码和解码、一个位数组以及几个杂项实用工具类。Contains the collections framework, some internationalization support classes, a service loader, properties, random number generation, string parsing and scanning classes, base64 encoding and decoding, a bit array, and several miscellaneous utility classes.
java.util.concurrent 在并发编程中通常有用的实用程序类。Utility classes commonly useful in concurrent programming.
java.util.concurrent.atomic 一个小型类工具包,支持对单个变量进行无锁线程安全编程。
java.util.concurrent.locks 接口和类提供了一个框架,用于锁定和等待与内置同步和监视器不同的条件。
java.util.function 函数接口为 lambda 表达式和方法引用提供目标类型。Functional interfaces provide target types for lambda expressions and method references.
java.util.jar 提供用于读取和写入 JAR(Java ARchive)文件格式的类,该格式基于标准 ZIP 文件格式和可选的清单文件。Provides classes for reading and writing the JAR (Java ARchive) file format, which is based on the standard ZIP file format with an optional manifest file.
java.util.random 此包包含支持用于随机数生成的通用 API 的类和接口。
java.util.regex 用于将字符序列与正则表达式指定的模式进行匹配的类。Classes for matching character sequences against patterns specified by regular expressions.
java.util.spi java.util 包中类的服务提供程序类。Service provider classes for the classes in the java.util package.
java.util.stream 用于支持对元素流的函数式操作的类,例如对集合的 map-reduce 转换。Classes to support functional-style operations on streams of elements, such as map-reduce transformations on collections.
java.util.zip 提供用于读取和写入标准 ZIP 和 GZIP 文件格式的类。
javax.crypto 提供用于加密操作的类和接口。
javax.crypto.interfaces 为 RSA 实验室的 PKCS #3 中定义的 Diffie-Hellman 密钥提供接口。Provides interfaces for Diffie-Hellman keys as defined in RSA Laboratories' PKCS #3.
javax.crypto.spec 为关键规范和算法参数规范提供类和接口。Provides classes and interfaces for key specifications and algorithm parameter specifications.
javax.net 为网络应用程序提供类。
javax.net.ssl 为安全套接字包提供类。
javax.security.auth 此包提供了用于身份验证和授权的框架。
javax.security.auth.callback 此包提供了服务与应用程序交互所需的类,以便检索信息(例如,包括用户名或密码的身份验证数据)或显示信息(例如,错误和警告消息)。
javax.security.auth.login 此包提供了一个可插入的身份验证框架。This package provides a pluggable authentication framework.
javax.security.auth.spi 此包提供了用于实现可插拔身份验证模块的接口。This package provides the interface to be used for implementing pluggable authentication modules.
javax.security.auth.x500 此包包含应用于在使用者中存储 X500 主体和 X500 专用凭据的类。This package contains the classes that should be used to store X500 Principal and X500 Private Credentials in a Subject.
javax.security.cert 提供公钥证书的类。

Services Provides FileSystemProvider Uses

AbstractChronology 年表 An abstract implementation of a calendar system, used to organize and identify dates. 日历系统的抽象实现,用于组织和标识日期。
AsynchronousChannelProvider 异步通道提供程序Service-provider class for asynchronous channels. 异步通道的服务提供程序类。
BreakIteratorProvider An abstract class for service providers that provide concrete implementations of the BreakIterator class.
CalendarDataProvider 一个抽象类,用于提供与区域设置相关的日历参数的服务提供程序。An abstract class for service providers that provide locale-dependent Calendar parameters.
CalendarNameProvider An abstract class for service providers that provide localized string representations (display names) of Calendar field values.
CharsetProvider Charset service-provider class.
Chronology 年表 A calendar system, used to organize and identify dates. 日历系统,用于组织和标识日期。
CollatorProvider An abstract class for service providers that provide concrete implementations of the Collator class. 一个抽象类,用于提供服务提供程序,提供Collator类的具体实现。
ContentHandlerFactory This interface defines a factory for content handlers. 此接口为内容处理程序定义工厂。
CurrencyNameProvider An abstract class for service providers that provide localized currency symbols and display names for the Currency class. 一个抽象类,用于为Currency类提供本地化货币符号和显示名称的服务提供商。
DateFormatProvider An abstract class for service providers that provide concrete implementations of the DateFormat class. 一个抽象类,用于提供DateFormat类的具体实现的服务提供程序。
DateFormatSymbolsProvider An abstract class for service providers that provide instances of the DateFormatSymbols class. 一个抽象类,用于提供DateFormatSymbols类实例的服务提供程序。
DecimalFormatSymbolsProvider An abstract class for service providers that provide instances of the DecimalFormatSymbols class. 一个抽象类,用于提供DecimalFormatSymbols类实例的服务提供程序。
FileSystemProvider Service-provider class for file systems. 文件系统的服务提供程序类。
FileTypeDetector A file type detector for probing a file to guess its file type. 文件类型检测器,用于探测文件以猜测其文件类型。
LocaleNameProvider An abstract class for service providers that provide localized names for the Locale class. 一个抽象类,用于为Locale类提供本地化名称的服务提供程序。
LoginModule Service-provider interface for authentication technology providers.
NumberFormatProvider An abstract class for service providers that provide concrete implementations of the NumberFormat class. 一个抽象类,用于提供NumberFormat类的具体实现的服务提供程序。
Provider This class represents a "provider" for the Java Security API, where a provider implements some or all parts of Java Security. 此类表示 Java 安全性 API 的"提供程序",其中提供程序实现 Java 安全性的部分或全部部分。
ResourceBundleControlProvider An interface for service providers that provide implementations of ResourceBundle.Control. 为服务提供商提供的接口,这些提供商提供ResourceBundle.Control的实现。
ResourceBundleProvider ResourceBundleProvider is a service provider interface for resource bundles. ResourceBundleProvider是资源包的服务提供程序接口。
SelectorProvider Service-provider class for selectors and selectable channels. 用于选择器和可选通道的服务提供商类。
System.LoggerFinder The LoggerFinder service is responsible for creating, managing, and configuring loggers to the underlying framework it uses. 该LoggerFinder服务负责创建、管理和配置记录器到它使用的基础框架。
TimeZoneNameProvider An abstract class for service providers that provide localized time zone names for the TimeZone class. 一个抽象类,用于为时区类提供本地化时区名称的服务提供商。
ToolProvider An interface for command-line tools to provide a way to be invoked without necessarily starting a new VM. 命令行工具的接口,用于提供一种无需启动新 VM 即可调用的方法。
URLStreamHandlerProvider URL stream handler service-provider class. URL 流处理程序服务提供程序类。
ZoneRulesProvider Provider of time-zone rules to the system. 向系统提供时区规则。

javapath [C:\ProgramData\Oracle\Java\javapath_target_60180781] 目录链接

java "-Djava.util.logging.config.file=new.properties" .\Main.java

在用户的家目录找到java0.log

System.setProperty("java -Djava.util.logging.config.file","new.properties"); 无效

javadoc 标签_新的Javadoc标签@ apiNote,@ implSpec和@implNote_dnc8371的博客-CSDN博客: https://blog.csdn.net/dnc8371/article/details/107265585
javadoc 标签

如果您已经在使用Java 8,则可能会看到一些新的Javadoc标签: @apiNote , @implSpec和@implNote 。 他们怎么了? 如果要使用它们,该怎么办?

总览
该帖子将快速查看标签的来源和当前状态。 然后,它将解释它们的含义并详细说明如何将它们与IDE,Javadoc工具一起使用,以及如何通过Maven的Javadoc插件使用。

我在GitHub上创建了一个演示项目,以显示一些示例和Maven pom.xml的必要补充。 为了使Maven规避变得更容易,它已经包含了生成的javadoc 。

语境
起源
新的Javadoc标记是JSR-335的副产品,它引入了lambda表达式。 它们是在默认方法的上下文中提出的,因为它们需要更标准化和更细粒度的文档。

2013年1月,Brian Goetz 提出了动机,并为这些新标签提出了建议 。 经过简短的讨论,三个星期后它变成了功能请求 。 到4月, JDK Javadoc制造商已更新 , 邮件列表通知他们可以使用了。

当前状态
重要的是要注意,新标签未正式记录(在Javadoc标签的正式列表中丢失),因此可能会发生变化。 此外,实施者Mike Duigou 写道 :

没有计划在JDK文档使用范围之外尝试普及这些特定标签。

因此,虽然理解它们的含义肯定有益,但是团队应该仔细考虑使用它们是否值得依靠无证行为带来的风险。 我个人认为,我认为已经在JDK上进行了大量投资,以至于无法撤消。 如果有必要,也可以在代码库中轻松删除或搜索/替换它们的出现。

由布鲁克林博物馆根据CC-BY 3.0发行 。

让我们切入事物的核心。 这些新标签的含义是什么? 它们在哪里以及如何使用?

含义
新的Javadoc标记在功能请求的说明中进行了很好的解释(我对布局进行了一些更改):

关于API中的方法,我们可能要记录很多事情。 从历史上看,我们将它们定义为“规范”(例如,必要的后置条件)或“实施说明”(例如,使用户了解引擎盖发生了什么的提示。)但是,实际上,有四个方框(和我们已经将它们塞入了两个,或者实际上是1.5):

{API,实现} x {规范,注释}

(我们有时使用规范性/信息性术语来描述规范/注释之间的差异。)以下是每个框中的内容的一些描述。

  1. API规范。
    这是我们认识和喜爱的。 一种描述,该描述同样适用于该方法的所有有效实现,包括前提条件,后置条件等。

  2. API注释。
    与API有关的评论,原理或示例。

3.实施规范。
在这里,我们说的是成为有效的默认实现(或类中的可重写实现)的含义,例如“ throws UOE”。 同样,这是我们描述putIfAbsent的默认值的putIfAbsent 。 正是从这个盒子中,将要实施的人获得了足够的信息,以就是否要覆盖做出明智的决定。

4.实施说明。
有关实现的信息性注释,例如特定于此版本此JDK中此类中的实现的性能特征,并且可能会发生变化。 允许这些内容在平台,供应商和版本之间有所不同。

建议:添加三个新的Javadoc标记@apiNote , @implSpec和@implNote 。 (剩下的框,API Spec,不需要新标签,因为已经使用了Javadoc。) @impl {spec,note}可以很好地应用于类中的具体方法或接口中的默认方法。

因此,新的Javadoc标记旨在对注释中给出的信息进行分类。 它区分方法的规范,类的规范...(与API的所有用户有关–这是“常规”注释,如果有的话将为@apiSpec ),以及其他更短暂或不太通用的文档。 更具体地说,API用户不能依赖任何用@implSpec或@implNote编写的内容 ,因为这些标记与方法的这种实现有关,而没有提及重写实现。

这表明使用这些标签将主要使API设计人员受益。 但是在这种情况下,即使是从事大型项目的Joe Developer也可以被视为设计师,因为他的代码肯定会在将来的某个时候被同事使用和/或更改。 在这种情况下,如果注释清楚地描述了API的不同方面,将很有帮助。 例如,它是方法规范的“线性运行”部分(因此不应降级)或当前实现的详细信息(因此可以更改)。

例子
让我们看一些例子! 首先从演示项目中展示如何使用标签的基本原理,然后从JDK看到其在生产中的使用。

彩票
该项目包含一个虚拟库中的界面Lottery 。 该接口最初包含在库的1.​​0版中,但是必须为1.1版添加新方法。 为了保持向后兼容性,这是默认方法,但是计划是在2.0版中使其抽象(给客户一些时间来更新其代码)。

使用新标签,该方法的文档可以清楚地区分其文档的含义:

Lottery.pickWinners的文件

/**

  • Picks the winners from the specified set of players.
  • The returned list defines the order of the winners, where the first
  • prize goes to the player at position 0. The list will not be null but
  • can be empty.
  • @apiNote This method was added after the interface was released in
  •      version 1.0. It is defined as a default method for compatibility
    
  •      reasons. From version 2.0 on, the method will be abstract and
    
  •      all implementations of this interface have to provide their own
    
  •      implementation of the method.
    
  • @implSpec The default implementation will consider each player a winner
  •       and return them in an unspecified order.
    
  • @implNote This implementation has linear runtime and does not filter out
  •       null players.
    
  • @param players
  •        the players from which the winners will be selected
    
  • @return the (ordered) list of the players who won; the list will not
  •     contain duplicates
    
  • @since 1.1
    */
    default List pickWinners(Set players) {
    return new ArrayList<>(players);
    }
    JDK
    JDK广泛使用新标签。 一些例子:

ConcurrentMap :
几个@implSpec定义默认实现的行为,例如在replaceAll 。
Objects使用@apiNote解释为什么添加了看似无用的方法isNull和nonNull 。
抽象类Clock在其类注释中使用@implSpec和@implNote来区分必须注意哪些实现以及如何实现现有方法。
遗产
当覆盖方法没有注释或通过{@inheritDoc}继承其注释时,不包括新标记。 这是一件好事,因为它们通常不适用。 要继承特定标签,只需将片段@tag {@inheritDoc}到注释中。

演示项目中的实现类检查了各种可能性。 自述文件提供了概述。

工具支援
集成开发环境
您可能希望在IDE中看到改进的文档(JDK的文档,也许是您自己的文档)。 那么,当前最受欢迎的人如何处理它们?

Eclipse显示标签及其内容,但不提供特殊的呈现方式,例如对标签标题进行排序或整理。 有一个功能要求来解决此问题。

IntellyJ的当前社区版本14.0.2既不显示标签也不显示其内容。 这显然已在平安夜解决(请参见票证 ),所以我想下一个版本将不再有此问题。 不过,我无法透露任何有关渲染的信息。

NetBeans既不显示标签也不显示内容,我找不到任何票证可以解决此问题。

总而言之,这不是一个漂亮的图片,但考虑到这不是官方的Javadoc功能,这是可以理解的。

生成Javadoc
如果您开始在自己的代码中使用这些标记,您将很快意识到由于未知标记,生成Javadoc失败。 这很容易解决,您只需要告诉它如何处理它们即可。

命令行
这可以通过命令行参数-tag来完成。 以下参数允许这些标签随处可见(例如,在软件包,类型,方法等上),并为它们提供JDK当前使用的标头:

向Javadoc讲述新标签

-tag "apiNote🅰️API Note:"
-tag "implSpec🅰️Implementation Requirements:"
-tag "implNote🅰️Implementation Note:"
(我阅读了官方文档,好像这些参数应该是-tag apiNote:a:“ API注意:” [请注意引号],但这对我不起作用。如果您想限制使用新标签或完全不包含它们, -tag的文档告诉您如何执行此操作。)

默认情况下,所有新标签都添加到生成文档的末尾,这会将它们放在下面,例如@param和@return 。 要更改此设置,必须按所需顺序列出所有标签,因此必须将已知标签添加到上述三个标签下方的列表中 :

在新标签之后列出已知标签

-tag "param"
-tag "return"
-tag "throws"
-tag "since"
-tag "version"
-tag "serialData"
-tag "see"
Maven
Maven的Javadoc插件具有配置设置标记 ,该标记用于详细创建相同的命令行参数。 GitHub上的演示项目展示了pom中的外观 。

反射
我们已经看到添加了新的Javadoc标记@apiNote , @implSpec和@implNote ,以允许将文档划分为具有不同语义的部分。 了解它们对每个Java开发人员都有帮助。 API设计人员可能选择在他们自己的代码中使用它们,但必须记住,它们仍然没有文档记录,因此可能会发生变化。

我们最终看了一些涉及的工具,发现需要改进IDE支持,但是可以对Javadoc工具和Maven插件进行参数化以充分利用它们。

翻译自: https://www.javacodegeeks.com/2015/01/new-javadoc-tags-apinote-implspec-and-implnote.html

posted @ 2022-01-04 20:44  CharyGao  阅读(242)  评论(0编辑  收藏  举报