Java17的Javadoc给出了在模块Y中声明包X的错误

k0pti3hp  于 2023-03-06  发布在  Java
关注(0)|答案(1)|浏览(193)

我正在使用maven-javadoc-plugin生成Java 17的Javadoc。由于我的代码中有一个类使用了jdk.internal.reflect.Reflection类,Javadoc给出了一个错误。我尝试使用传递--add-opens标志,但没有用。

<plugin>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.2.0</version>
    <executions>
        <execution>
            <id>attach-javadocs</id>
            <phase>install</phase>
            <goals><goal>jar</goal></goals>
        </execution>
    </executions>
</plugin>

它得到下面的错误.

import jdk.internal.reflect.Reflection;
[ERROR]                    ^
[ERROR]   (package jdk.internal.reflect is declared in module java.base, which does not 
export it to the unnamed module)
[ERROR] 1 error
[ERROR]
[ERROR] Command line was: cmd.exe /X /C ""C:\Program Files\Java\jdk-17.0.1\bin\javadoc.exe" @options @packages"
e0bqpujr

e0bqpujr1#

对于任何有困难的人,maven-javadoc-plugin的文档中说使用additionalOption标记和-J标记(ref),但在我的例子中它没有传递标记。

<plugin>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.2.0</version>
    <configuration>
    <additionalJOption>
       --add-exports java.base/jdk.internal.reflect=ALL-UNNAMED
    </additionalJOption>
    </configuration>
    <executions>
        <execution>
            <id>attach-javadocs</id>
            <phase>install</phase>
            <goals><goal>jar</goal></goals>
        </execution>
    </executions>
</plugin>

相关问题