How to link javadoc to private field? [duplicate]
The syntax is fine, both the following work within a class (and there's no reason to link to a private field from a different class):
public class Demo {
private int num = 0;
/**
* Access field {@link Demo#num} / {@link #num} ...
*/
private void foo() { ... }
...
When generating the javadoc, e.g., via ant, just specify that private fields should be included (the default minimum access is "protected", not "private"):
<target name="javadoc" depends="compile" description="gen javadoc">
<javadoc destdir="build/docs"
author="true"
version="true"
use="true"
access="private"
windowtitle="Demo API">
<fileset dir="src/main" defaultexcludes="yes">
<include name="com/**"/>
</fileset>
<doctitle><![CDATA[<h1>Test</h1>]]></doctitle>
<link offline="true" href="http://download.oracle.com/javase/6/docs/api/" packagelistLoc="doc"/>
</javadoc>
</target>
I think what you are writing in the comments is fine, you just need to tell JavaDoc to also include private fields in the documentation. JavaDoc has an option -private for this. Check this answer.