2

I'm using maven-javadoc-plugin to produce Javadoc with Java 17. Since there is a class in my code that uses jdk.internal.reflect.Reflection class, Javadoc gives an error. I tried using to pass --add-opens flag but it's no use.

<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>

It get the error below.

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"

1 Answers1

1

For anyone struggling, maven-javadoc-plugin's documentation says use the additionalOption tag with -J flag(ref) but in my case it didn't pass the flag. So I used the plugin with the configuration below:

<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>