How do I make a reference, in javadoc, to a method parameter, so that the reference can be refactored ?
For example:
public class A {
private int field;
/**
* @param p
* {@link #field} is initialized using the value of p.
*/
void foo(int p)
{
//...
}
}
If I rename parameter p in the above code, I want
"...using the value of p"
text to change accordingly (just as renaming field will change {@link #field}
).
I read this old post, and some more sources, but could not find a way to do it.
Does javadoc support it ?
Due to Java erasure, method argument names are ephemeral, they are not part of the static class definition. So, void foo(int p)
being changed to void foo(int x)
is not considered refactoring, because it is guaranteed that it will not affect the program's logic in any way (unless the argument is overloading a class field).
So in the javadoc there cannot be a static link that identifies the method argument. The mere fact that the word after @param
changes when you refactor the method is a favor offered by the IDE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With