java如何理解这个Javadoc“未找到引用”错误?
TLDR:问题在底部
考虑这样的场景:
a/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,我不应该在构造函数的文档中放置@throw
,那么除了在异常中之外,还有什么地方可以描述错误条件呢
我说的不是一个格式错误的@link
或其他什么,而是关于访问冲突的“仅仅”警告,这是对的吗?还是应该用不同的格式?这是预期的行为吗
共 (0) 个答案