jdk1.7升级到jdk1.8后出错: [ERROR] javadoc: warning - Multiple sources of package comments found for package

from: http://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html

[ERROR] javadoc: warning - Multiple sources of package comments found for package

Turning off doclint in JDK 8 Javadoc

JDK 8 includes many updates, but one is I suspect going to cause quite a few complaints - doclint for Javadoc.

Javadoc doclint

Documentation is not something most developers like writing. With Java, we were fortunate to have the Javadoc toolset built in and easy to access from day one. As such, writing Javadoc is a standard part of most developers life.

The Javadoc comments in source code use a mixture of tags, starting with @, and HTML to allow the developer to express their comment and format it nicely.

Up to JDK 7, the Javadoc tool was pretty lenient. As a developer, you could write anything that vaguely resembled HTML and the tool would rarely complain beyond warnings. Thus you could have @link references that were inaccurate (such as due to refactoring) and the tool would simply provide a warning.

With JDK 8, a new part has been added to Javadoc called doclint and it changes that friendly behaviour. In particular, the tool aim to get conforming W3C HTML 4.01 HTML (despite the fact that humans are very bad at matching conformance wrt HTML).

With JDK 8, you are unable to get Javadoc unless your tool meets the standards of doclint. Some of its rules are:

  • no self-closed HTML tags, such as <br /> or <a id="x" />
  • no unclosed HTML tags, such as <ul> without matching </ul>
  • no invalid HTML end tags, such as </br>
  • no invalid HTML attributes, based on doclint‘s interpretation of W3C HTML 4.01
  • no duplicate HTML id attribute
  • no empty HTML href attribute
  • no incorrectly nested headers, such as class documentation must have <h3>, not <h4>
  • no invalid HTML tags, such as List<String> (where you forgot to escape using &lt;)
  • no broken @link references
  • no broken @param references, they must match the actual parameter name
  • no broken @throws references, the first word must be a class name

Note that these are errors, not warnings. Break the rules and you get no Javadoc output.

In my opinion, this is way too strict to be the default. I have no problem with such a tool existing in Javadoc, but given the history of Javadoc, errors like this should be opt-in, not opt-out. Its far better to get slightly broken Javadoc than no Javadoc.

I also haven‘t been able to find a list of the rules, which makes life hard. At least we can see the source code to reverse engineer them.

Turning off doclint

The magic incantation you need is -Xdoclint:none. This goes on the command line invoking Javadoc.

If you are running from maven, you need to use the additionalparam setting, as per the manual. Either add it as a global property:

  <properties>
    <additionalparam>-Xdoclint:none</additionalparam>
  </properties>

or add it to the maven-javadoc-plugin:

  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-javadoc-plugin</artifactId>
      <configuration>
        <additionalparam>-Xdoclint:none</additionalparam>
      </configuration>
    </plugin>
  </plugins>

Ant also uses additionalparam to pass in -Xdoclint:none, see the manual.

Gradle does not expose additionalparam but Tim Yates and Cedric Champeau advise of this solution:

  if (JavaVersion.current().isJava8Compatible()) {
    allprojects {
      tasks.withType(Javadoc) {
        options.addStringOption(‘Xdoclint:none‘, ‘-quiet‘)
      }
    }
  }

See also the Gradle manual.

Summary

I don‘t mind doclint existing, but there is no way that it should be turned on to error mode by default. Getting some Javadoc produced without hassle is far more important than pandering to the doclint style checks. In addition, it is very heavy handed with what it defines to be errors, rejecting plenty of HTML that works perfectly fine in a browser.

I‘ve asked the maven team to disable doclint by default, and I‘d suggest the same to Ant and Gradle. Unfortunately, the Oracle team seem convinced that they‘ve made the right choice with errors by default and their use of strict HTML.

Comments welcome, but please note that non-specific "it didn‘t work for me" comments should be at Stack Overflow or Java Ranch, not here!

时间: 2024-10-01 03:28:45

jdk1.7升级到jdk1.8后出错: [ERROR] javadoc: warning - Multiple sources of package comments found for package的相关文章

Linux JDK1.7升级到JDK1.8

第一种RPM包升级: rpm -qa | grep jdk jdk-1.7.0_37-fcs.x86_64 rpm -qa | grep gcj libgcj-4.4.7-4.el6.x86_64 rpm -e --nodeps jdk-1.7.0_37-fcs.x86_64 rpm -e --nodeps libgcj-4.4.7-4.el6.x86_64 再次检查JDK版本,卸载成功: java -version -bash: ./usr/bin/java: No such file or 

PInvoke在 2.0 3.0的时候正常 升级到4.0后出错。

方法1: 设置 CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl,但是我设置了也是出错.换一个convention没出错.但是调用不正常. 方法2: 大概意思是P/Invoke StackImblance这个异常,本身来说可以忽略掉. 在.net 2的项目环境下,默认是关掉这个异常检查的.在.net 4下面,默认是开启这个检查的. 要解决这个问题,可以在ctrl+alt+e的处理异常类型类型设定里

Java jdk1.6 升级到1.7

最新在做项目时碰到电脑默认安装的java jdk1.6,但自己的项目所用到的java jdk1.7. 因此打算将jdk1.6升级到1.7,而又不能影响使用jdk1.6的程序.现将升级方法总结如下: 1.    C:\Windows\System32中将jdk1.6的java.exe,javac.exe,javaw.exe,npdeployJava1.dll,deployJava1.dll替换成jdk1.7对应的文件: 2.    Jdk1.6默认的安装文件C:\Program Files\Jav

mysql从5.6升级到5.7后出现 Expression #1 of ORDER BY clause is not in SELECT list,this is incompatible with DISTINCT

[问题]mysql从5.6升级到5.7后出现:插入数据和修改数据时出错Caused by: com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred while applying a parameter map. --- Check the findOrderList-InlineParameterMap. --- Check the statement (query failed). --- Caus

解决MFC应用程序在调整系统比列放大后出错问题心得

公司有一个屏幕书写的软件,06年开始开发的,至今已八年之久,目前处于维护阶段,在接到这个任务前我也没机会接触这个项目的代码 日前,客户反应在系统比列调整为150%出现界面显示不正常.笔记偏移.笔记画出屏幕崩溃等问题.更坑人的是,经过测试部测试发现在不同的主机上有不同的现象,后来在我的自己的开发机上运行有问题,但是比较少.因为我现任的直属领导就是当前这个项目的主力之一,他也觉得很诡异,让我更诡异的是他居然帮这个任务交给了我. 好吧,硬着头皮上吧,花了三天时间来熟悉代码和软件,在这个过程中发现有时重

win7下安装matlab后打开出错&ldquo;error starting desktop&rdquo;的解决办法

在matlab快捷图标上右键,选择"还原以前的版本"--"兼容性"选项卡,在"以兼容模式运行这个程序"前面打勾,并选择"windows vista",在下面的"特权等级"中,勾选"以管理员身份运行此程序".OK,到这里就解决了.[注意]是用"windows vista"系列的兼容模式,不要用XP兼容模式!   参考自:http://zhidao.baidu.com/l

升级macOS新系统后,Xcode7.2 Xcode7.3.1 在新建项目界面,出现了文字错乱的情况

在升级macOS新系统后,Xcode7.2  Xcode7.3.1 在新建项目界面,出现了文字错乱的情况. 这种情况在Xcode8.0环境下是显示正常的,但是在7.2  .7.3.1环境下面是出现了错乱的情况. 暂时没在网上找到相关可靠的解释或者说明.

如果拦截WebView的错误和OS升级到4.4后链接不能点击的问题

android OS升级到4.4之后,有些WebView的链接我们点击无效了,下面可以解决其中的某一种情况: webviewClient的shouldOverrideUrlLoading方法必须返回false,返回true会导致这个问题 有时候PM会有一种需求,如果不是Server那边的问题,那么想在界面上显示自定义的错误(如遇到连接到WIFI CMCC而没有移动的密码,手机显示着连接上了WIFI) 这时我们需要去截获WebView的error,可以通过重载setWebViewClient的方法

django从1.7升级到1.9后 提示:RemovedInDjango110Warning

Django项目,把django从1.7升级到1.9后,大量报错.需要做如下修改. 1,修改urls.py: 在django1.9里,urls的配置不再支持字符串型的路由.需要先import,然后直接引用.更加清晰. 比如: urlpatterns = patterns('', url(r'^test/',  'httpServer.views.hello.test'),     # 注意,字符串形式 ) 改为: from httpServer.views import hello # urlp