在OpenJDK 11的源代码上运行DocumentationTool

时间:2019-04-12 22:26:58

标签: java clojure javadoc

我正在尝试在OpenJDK 11的源代码上运行DocumentationTool

输出看起来像这样:

Constructing Javadoc information...
/Users/Borkdude/git/openjdk-jdk11/src/java.base/share/classes/java/lang/IllegalStateException.java:26: error: package exists in another module: java.base
package java.lang;

重复大约100次。

我在Clojure中的代码如下:

(import '[javax.tools ToolProvider])
(let [dt (ToolProvider/getSystemDocumentationTool)
        fm (.getStandardFileManager dt nil nil nil)
        files (.getJavaFileObjectsFromFiles
               fm
               (filter #(str/ends-with? (.getPath %) ".java")
                       (file-seq (io/file "/Users/Borkdude/git/openjdk-jdk11/src/java.base/share/classes/java/lang"))))
        task (.getTask dt nil fm nil nil nil files)]
    (.call task))

如何摆脱错误:

error: package exists in another module: java.base
package java.lang;

1 个答案:

答案 0 :(得分:0)

您可以编译整个模块,或者需要“修补”模块。这是每个示例的示例,假设您将src.zip解压缩到/tmp

要编译整个模块:

(import '[javax.tools ToolProvider])
(require '[clojure.string :as str])

(let [dt (ToolProvider/getSystemDocumentationTool)
      fm (.getStandardFileManager dt nil nil nil)
      files (.getJavaFileObjectsFromFiles
             fm
             (filter #(str/ends-with? (.getPath %) ".java")
                     (file-seq (io/file "/tmp/src/java.base/"))))
      task (.getTask dt nil fm nil nil nil files)]
  (.call task))  

要修补模块(即仅编译某些源代码):

(let [dt (ToolProvider/getSystemDocumentationTool)
      fm (.getStandardFileManager dt nil nil nil)
      files (.getJavaFileObjectsFromFiles
             fm
             (filter #(str/ends-with? (.getPath %) ".java")
                     (file-seq (io/file "/tmp/src/java.base/java/lang"))))
      opts ["--patch-module" "java.base=/tmp/src"]
      task (.getTask dt nil fm nil nil opts files)]
  (.call task))