java中缺少javadoc_Java 8中不完整的Javadoc?

javadocs for Java is the 8不完全?P></

方法对omitted are some of the method and the description is copied from a(incorrectly)基础类(例如toString()java.util.intsummarystatistics the method with the笔记"description copied from class对象"。P></

public String toString()

Description copied from class: Object

Returns a string representation of the object. In

general, the toString method returns a string that

"textually represents" this object. The result should be a concise

but informative representation that is easy for a person to read. It

is recommended that all subclasses override this method.

The toString method for class Object returns a

string consisting of the name of the class of which the object is an

instance, the at-sign character '@', and the unsigned

hexadecimal representation of the hash code of the object. In other

words, this method returns a string equal to the value of:

getClass().getName() + '@' + Integer.toHexString(hashCode())

Overrides:

toString in class Object

Returns:

a string representation of the object.

the actual toString方法特异性信息:返回舱这样P></

IntSummaryStatistics{count=10, sum=129, min=2, average=12.900000, max=29}

默认的类和对象inherited not the from here,as shown。P></

我们认为,这是一个可能。在这个文件copied)说,"一些方法返回的字符串表示的细节",只有从字符串表示的对象类(不可以说是没有在其他任何其他类别的字符串表示形式返回)。在任何的情况下,你可能不应该依赖于任何特定的表示,因为这是一个实现的细节,可能会改变以后。

也有一个:"然而,它是安全的使用collectors.tointstatistics(S)",但它现在被称为summarizingInt。

我同意,这应该是固定的。谢谢你为这个指责。+1

谢谢问这个问题。它有一些错误出现的JDK文档。

特写:如何对选民的意见-这是基于什么?问题出在目前的问题已经有一个具体的解决方案。

"他让我想起了"谋杀":"这只是你的意见,不是人。"使它的操作系统。有一个javadocs所说的标准应该是明确的,这至少一个局部的错误。"斯图尔特_标志错误和已打开的最终决策,这是否是一个问题的意见将取决于,至少在局部的,解决这些错误。

是的,这里有几个不同的问题。

IntSummaryStatistics.toString规范有一些文本是从Object.toString复制过来的,它会覆盖这些文本。第一部分是正确的:

Returns a string representation of the object. In general, the toString method returns a string that"textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

这表示Object.toString定义的合同,并对所有子类施加要求。

从Object.toString复制的规范的第二部分是:

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character '@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

getClass().getName() + '@' + Integer.toHexString(hashCode())

这是正确的,但不相关,因为它在IntSummaryStatistics.toString的规范中讨论了Object.toString的实现。把这个复制到这里是不合适的。注意,这是关于Object.toString的实施,而不是关于需要实施覆盖的合同。

问题是,在IntSummaryStatistics.toString的文档注释中使用的javadoc {@inheritDoc}指令复制了整个内容,而实际上只需要复制部分内容。具体来说,应复制对子类施加的合同,但不应复制实施规范。

直到JDK8没有办法将它们分开,所以文本要么是手工复制(导致不一致),要么是使用{@inheritDoc},复制不需要的内容。在JDK8中,引入了一些新的javadoc标记,如@implSpec(实现规范),将文档注释分为不同的部分。{@inheritDoc}指令可以选择性地继承这些部分,而不是继承整个文档。不幸的是,这些标签在本例中没有使用,所以我们有一些清理工作要做。

新的标签记录在这个信息性的jep中。注意,这些标签是JDK特有的,还不能用于JDK之外的JavaDoc。

还有一件丢失了。Object.toStringdoc注释在概念上分为一部分定义子类上的合同和一部分定义其实现。理想情况下,我们希望将合同部分复制到IntSummaryStatistics.toString文档中,并希望有另一部分定义IntSummaryStatistics.toString的实现。原来有,但看不见!IntSummaryStatistics.toString的源代码将其作为文档注释:

@Override

/**

* {@inheritDoc}

*

* Returns a non-empty string representation of this object suitable for

* debugging. The exact presentation format is unspecified and may vary

* between implementations and versions.

*/

public String toString() { ...

不幸的是,文本"返回非空字符串表示…"没有出现在JavaDoc输出中。我觉得这是另一个错误。编辑:错误是注释在@Override注释和方法声明的其余部分之间。文档注释必须位于整个方法声明之前,包括注释。所以这个注释看起来像一个Doc注释,但是由于它位于错误的位置,JavaDoc忽略了它。

我已经提交了JDK-80449和JDK-8080450来涵盖这些问题。

回答得很好!!!!

JDK-8080450已在JDK 9中修复。

我想说你是对的,这里有什么问题。此toString()方法记录在InSummaryStatistics JavaDoc页上。它没有在"从类对象派生的方法"链接中引用。所以我想说,如果这个方法的行为与object.toString()不同,那么应该记录该行为。

谢谢!是否可以报告此问题以进行更正?

报告一下,请把他们说的话汇报一下。我可能错了,但这对我来说似乎不正确。

我不知道JavaDoc文档遗漏的报告——只有Java错误。你知道吗?

由于@stuartu marks已经编写了bug,现在可能已经无关紧要了,但是您可以根据文档输入bug。文档是JDK的一部分,它可能有缺陷。

我不同意称这是"错误的"。但它误导了类Object是如何实现toString()的,因为实际上实现与此不同。

我认为这部分不应该被复制。这是误导性的,并没有添加可利用的信息。

但我完全同意这种形式的文档有点"不正确",对于这样的公共API来说是不值得的。即使没有任何文档比这个文档更好。

哪个部分正确?一切都无关紧要!

@乔纳森,是的,这是不相干和误导,但正确的。类Object按照描述的方式实现toString()。

文档应该记录方法没有陈述正确但不相关的事实。根据你的测量,医生可能会说"奶牛是食草动物",是正确的,但不相关。对我来说,这是一种不正确的文档形式。

在这种情况下,我完全同意将文件格式称为"不正确"。这从"复制和粘贴"开始,这是邪恶的…

@乔纳森整个第一段是正确的和相关的。只有第二段不应包括在内。请注意,它也不应该是Object.toString()的javadoc的一部分,它只是一个小的实现细节。

@biziclop第一段仅在类对象中相关,在类对象中它指导开发人员以特定于类的方式重写toString。在ToString返回以逗号分隔的统计信息列表的类中,它是不相关的。

@约拿单,因为这是你应该知道的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值