Javadoc:“继承自"的方法之间的区别和“方法声明为" [英] Javadoc: Difference between "Methods inherited from" and "Methods declared in"

查看:84
本文介绍了Javadoc:“继承自"的方法之间的区别和“方法声明为"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于Java的JDK Java文档< 10中有一个称为继承自方法"的部分,其中列出了在父类/接口中声明的方法.但是从Java 10开始,此部分称为声明的方法".

The JDK Java docs for Java < 10 have a section called "Methods inherited from" which lists methods which are declared in the parent class / interface. However starting with Java 10 this section is called "Methods declared in".

为进行比较:

  • Java 8: java.lang.Number
  • Java 12: java.lang.Number

它们之间是否有区别?或者这仅仅是部分名称的改变?

Is there a difference between them or is this only a change of the section name?

推荐答案

在Java 10中,选项

In Java 10 the option --override-methods (detail|summary), was added to the javadoc command:

  • Release notes
  • JDK-8157000: Feature request
  • JDK-8187386: Tracking the addition to javadoc

目的是减少方法的实现或重写时的噪音,但是文档保持不变.

The intention was to reduce the noise when methods are implemented or overridden, but the documentation remained unchanged.

在不指定override-methods的情况下使用javadoc时,默认为detail模式.

The detail mode is the default when you use javadoc without specifying override-methods.

它表现出以前生成文档的方式:

It behaves the way the documentation has been generated before:

  • 如果未重写方法,它将位于继承自的方法"部分.
  • 如果某个方法被覆盖,则无论其签名或文档是否更改,该方法都将记录在方法详细信息"下.
  • 如果某个方法被覆盖并且被更改,则该文档将记录在方法详细信息"下.
  • 否则,它将在声明的方法"下列出.
  • If a method is overridden and its documentation is changed, it will be documented under "Method Detail".
  • Otherwise it will be listed under "Methods declared in".

summary模式现在用于生成JDK文档( JDK-8189706 ).

The summary mode is now used to generate the JDK documentation (JDK-8189706).

请注意,此模式当前存在错误,因为它忽略了应该记录的方法签名的某些更改,请参见 JDK-8223607 .

Be aware that this mode is currently bugged because it ignores some changes to the method signature which should be documented, see JDK-8223607.

您将看到继承自方法"或声明的方法"部分.
当比较同一类的两个文档(一个文档带有继承自",另一个文档带有声明于")时,那么一个带有继承自"的文档可能会在方法详细信息"下列出更多方法,而对于声明于"第一,有些方法则在声明于"部分中.

You will either see a "Methods inherited from" or a "Methods declared in" section.
When comparing two documentations (one with "inherited from", the other with "declared in") for the same class, then the one with "inherited from" might list more methods under "Method Detail", while for the "declared in" one, some methods are instead in the "declared in" section.

是的,它们之间是有区别的.

So yes, there is a difference between them.

例如,对于java.time.temporal.ChronoUnit类,可以看到行为上的差异:

The difference in behavior can be seen for example for the java.time.temporal.ChronoUnit class:

  • Java 8: Listed under "Method Detail"
  • Java 12: Contained in "Methods declared in class java.lang.Enum"; see also the source to verify that the method is actually overridden

这篇关于Javadoc:“继承自"的方法之间的区别和“方法声明为"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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