jdk 8的Java Doclet API更改 [英] Java Doclet API change for jdk 8

查看:184
本文介绍了jdk 8的Java Doclet API更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java的新手。我试图升级到jdk 1.8,并在进行gradle测试时发现以下错误:

I am a newbie to Java. I was trying to upgrade to jdk 1.8 and found the following errors on doing a "gradle test":

/u01/sv/home/sv900t1/sv_test/Test_Suites/SeleniumLibraries/src/main/java/com/csgi/svtest/selenium/CustomWriter.java:57: error: cannot find symbol
        h2("Class "+classDoc.toString());
        ^
  symbol:   method h2(String)
  location: class CustomWriter
/u01/sv/home/sv900t1/sv_test/Test_Suites/SeleniumLibraries/src/main/java/com/csgi/svtest/selenium/CustomWriter.java:58: error: cannot find symbol
        printHyperLink(classDoc.toString()+".html","","Class description<br>",true);
        ^
  symbol:   method printHyperLink(String,String,String,boolean)
  location: class CustomWriter

我提到了 http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/com/sun/ tools / doclets / formats / html / SubWriterHolderWriter.java /

http://grepcode.com/file/repository。 grepcode.com/java/root/jdk/openjdk/7u40-b43/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java/

(我们的代码导入此:import com.sun.tools.doclets.formats.html.SubWriterHolderWriter;)

(our code imports this: import com.sun.tools.doclets.formats.html.SubWriterHolderWriter;)

并发现许多api如h2(),printHyperLink( ),hr( ),table(),tableHeaderStart(),tableHeaderEnd(),tableEnd(),pre(),strong(),preEnd(),ul(),print(),li(),ulEnd(),printHtmlHeader(),中心(),today(),printTop(),navLinks(),printBottom()和printBodyHtmlEnd()已被删除。

and found that many apis like h2(), printHyperLink(), hr(), table(), tableHeaderStart(), tableHeaderEnd(), tableEnd(), pre(), strong(), preEnd(), ul(), print(), li(), ulEnd(), printHtmlHeader(), center(), today(), printTop(), navLinks(), printBottom() and printBodyHtmlEnd() have been removed.

是否有可以启用的快速解决方法我们绕过符号错误?
或者我们应该用现有的api替换丢失的api。对我来说这看起来很多 - 作为一个参赛者。有关于如何做到这一点的现有例子吗?我已经在网上搜索了很多,但找不到任何有用的东西。

Is there a quick workaround that can enable us to bypass the symbol errors? Or should we replace the missing apis with existing ones. This looks like a lot of work to me - being an entrant. Are there any existing examples on how to do that? I have searched the internet a lot, but could not find anything useful.

CustomWriter.java中的代码用于使用自定义系统测试标记输出Javadoc页面。任何帮助表示赞赏 - 我们的时间很短。

The code in CustomWriter.java is for outputting a Javadoc page using custom System Test tags. Any help is appreciated - we are short on time.

推荐答案

这就是问题所在。 com.sun.tools。* 包中的类应被视为内部API。 Java文档中有明确的警告说你不应该编写针对这些API的代码。

Well here's the problem. The classes in the com.sun.tools.* packages should be treated as internal APIs. There are clear warnings in the Java documentation that say that you should not write code that against these APIs.

例如:

  • Why Developers Should Not Write Programs That Call 'sun' Packages
  • Closing the closed APIs

在Java 8中,代码尝试的类的标题使用说:

In Java 8, the header of the class that your code is trying to use says:


这不是任何支持的API的一部分。如果您编写的代码依赖于此,您需要自担风险。此代码及其内部接口如有更改或删除,恕不另行通知。

(粗体是原始的! )

它没有在Java 7中说明(哎哟!)确实有一些Javadoc FAQ的版本似乎鼓励人们重用标准的doclet类。不幸的是,甲骨文已经决定关闭这些类,并且还做了一些突破性的API更改,这加强了这一点,无论是否有意改变

It didn't say that in Java 7 (ouch!) Indeed there are versions of the Javadoc FAQ which seem to encourage people reuse the standard doclet classes. Unfortunately, Oracle have decided to close off these classes, and have also made some breaking API changes which reinforces this, whether or not that was the intention of the changes

什么可以你做到了吗?不幸的是,没有简单的解决方案:

What can you do about it? Unfortunately, there is no easy solution:


  • 也许您可以找到一个可以修改的真正开源的Doclet代码库。

  • Maybe you could find an truly open source Doclet codebase that you could modify.

也许你可以找到一位为你工作的商业供应商或顾问。

Maybe you could find a commercial vendor or consultant who will do the work for you.

或许你只是吮吸它并重写你的代码以使用最新版本的(内部)API。并且有可能在将来可能需要更多的痛苦。

Or maybe you just "suck it up" and rewrite your code to work with the latest version of the (internal) APIs. And live with the possibility that you may need to take more pain in the future.

或者......你可以在构建/测试盒上重新安装Java 7并使用它(只是)来运行自定义doclet。

Or ... you could reinstall Java 7 on your build / test boxes and use it (just) for running your custom doclets.

更新 - 已经指出上面的规则适用于 sun。* 包。但是:

UPDATE - It has been pointed out that the "rule" above is for sun.* packages. However:


  • 该文档没有说明 com.sun。* 包,因此无法推断它们与 java。* javax。* 以及明确声明为Java支持的API保留的其他内容。

  • The document doesn't say anything about com.sun.* packages, so it is not valid to infer that they fall into the same category as java.*, javax.* and others that are explicitly stated to be reserved for Java supported APIs.

还有 com.sun的其他示例。 * 明确声明不受支持的软件包。例如,Oracle的Java 8兼容性指南说这样的话:

There are other examples of com.sun.* packages that are explicitly stated to be NOT supported. For example, Oracle's "Compatibility Guide for Java 8" says things like this:


com.sun.media.sound package是一个内部的,不受支持的包,不适合外部应用程序使用。

The com.sun.media.sound package is an internal, unsupported package and is not meant to be used by external applications.

JDK内部包 com.sun.corba.se 和子包已添加到受限软件包列表中,并且在与安全管理器一起运行时无法直接使用。

The JDK internal package com.sun.corba.se and sub-packages have been added to the restricted package list and cannot be used directly when running with a security manager.

apt工具和包含在 com.sun.mirror 包中的关联API已在此版本中删除。

The apt tool and its associated API contained in the package com.sun.mirror have been removed in this release.


结论,即使没有明确声明 com.sun。* 包是内部的,Oracle是>>现在<<当它们适合时将它们视为内部。在某些情况下,回顾性地。

Conclusion, even if there is no explicit statement that com.sun.* packages are internal, Oracle is >>now<< treating them as internal when it suits them. In some cases, retrospectively.

这篇关于jdk 8的Java Doclet API更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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