When a class overrides a concrete method or implements and abstract method, the Javadoc is automatically inherited unless explicitly overwritten.
Or, at least the tool tries to do this. It seems it does not work for linked external APIs. For instance, when I in my code implement java.util.Map
, or something else from the JRE, the javadocs are not inherited/copied from the JRE javadocs/apidocs.
In my specific case, I am trying to configure this in the Maven2 Javadoc plugin, but it is the same when I run the javadoc CLI tool directly.
My Maven2 Javadoc plugin configuration currently looks like this:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<configuration>
<stylesheet>maven</stylesheet>
<links>
<link>http://download.oracle.com/javase/6/docs/api</link>
</links>
</configuration>
</plugin>
</plugins>
</reporting>
Any pointers on how to make this work?
As @Stephen mentioned, the source file for the inherited method must be available and must be on the path specified by
-sourcepath
. This is explained in the Javadoc tool documentation:So you'd have to use the
<sourcepath>
optional configuration parameter of the javadoc plugin (which contains by default the sources of the project).By the way,
<links/>
are something else,<links/>
are used to add cross reference links to external projects. And actually, they shouldn't be used for the JDK. From Configuring links:Assuming you configured a 1.6
source
level in the compiler plugin, cross references links to the Java API just works (links point to http://download.oracle.com/javase/6/docs/api/), there is nothing to add for the Java API.Weird. Did you actually specify the complier
source
level as documented? Just in case, here is what works for me:I cannot give you a definitive answer, but I think that the missing piece in the puzzle is that the
javadoc
utility needs to be able to find the source code of the relevant external APIs for javadoc inheritance to work.I had a similar question on StackOverflow which helped me solve this problem better than the accepted answer of this questsion: maven-javadoc-plugin and inheritDoc for Java API core classes
Summary: In order to inherit the Javadoc from Java core classes, you need to unzip their sources and include them in the Javadoc build. The sources of the Java core classes are are provided in a
src.zip
file within the JDK distro.