TLDR:问题在底部。
考虑这样的场景:
一个/ A.java
package a;
/** A class designed for inheritance. */
public class A {
/** An amazing enum! */
protected enum AEnum {
/** A wonderful value. */
A1,
/** A marvellous value. */
A2
}
/**
* Subclasses can call this constructor.
*
* @param ae may very well be {@link AEnum#A1}!
*/
protected A(AEnum ae) { }
};
B / B.java
package b;
import a.A;
/** My second class, so happy! */
public class B {
/**
* A constructor of {@link B}, takes an instance of {@link A}.
* Maybe I want to say that something depends on whether
* {@code aInstance} was constructed with {@link a.A.AEnum#A1}?
*
* @param aInstance (hmm, what could {@code aInstance} be? ;-)
*/
public B(A aInstance) { }
};
Javadoc抱怨这一行:
src/b/B.java:10: error: reference not found
* {@code aInstance} was constructed with {@link a.A.AEnum#A1}?
^
但是在编译的HTML中,无论如何都会创建指向相应enum
值的正确链接。我对这个错误感到困惑,为什么当它被发现时报告为“未找到”时为什么会报告?
现在当然想要引用我protected
无法访问的B
元素是很奇怪的,但这不是代码,只是文档。我相信有些情况是合理的。我在定义一个未经检查的异常(将所有异常保存在一个单独的包中)时遇到了这个问题,并解释如果原始类的protected
构造函数被调用某个特定设置并且违反了合同,则会抛出它。我读到here我不应该在构造函数的doc中添加@throw
,那么在哪里描述错误条件而不是异常呢?
我是对的,而不是格式错误的@link
或者此错误“仅仅”是关于访问冲突的警告?或者应该采用不同的格式?这是预期的行为吗?