java - 为什么 Eclipse 在另一个类中使用时不能处理 @value?

标签 java eclipse javadoc

我希望来自 A_CONSTANT 的字符串成为 ClassB 注释的一部分:

package my.stuff;

public class ClassA {
    /** Shows the string just fine: {@value} */
    public static final String A_CONSTANT = "show this in comments";
}

package my.stuff;

/**
 * Does not give me the string: {@value my.stuff.ClassA#A_CONSTANT}
 * Neither does this: {@value ClassA#A_CONSTANT}
 * 
 * @see my.stuff.ClassA#A_CONSTANT
 */
public class ClassB {

}

ClassA 中的 {@value} 将鼠标悬停在常量名称上时显示字符串内容;没关系。

此外,@see 标记通过链接到 A_CONSTANTClassB 中发挥作用。

但是 ClassB 中的两次 {@value ...} 尝试都失败了:我看到了文字 {@value ...}部分而不是 A_CONSTANT 悬停在 ClassB 上时的内容。

documentation告诉我使用以下我认为我做过的符号:{@value package.class#field}

this question 的答案还建议使用上述符号。

This与我的问题基本相同,但没有得到回答。

如何在其他类的注释中显示常量的字符串内容?

我在 Windows 7 x86 上使用 Eclipse Juno。

提前致谢。

编辑:

在我的项目上运行 javadoc.exe 时 {@value my.stuff.ClassA#A_CONSTANT} 解析为正确的字符串。

这就是为什么我稍微改变了问题:

为什么 Eclipse 在鼠标悬停时不显示常量的字符串,而 javadoc.exe 没有问题?

Mouse over in Eclipse: Constant's string is not shown

最佳答案

这似乎是 Eclipse 中的错误。稍微修改 the docs 中的示例:

public class TestClass {
  /**
   * The value of this constant is {@value}.
   */
  // In Eclipse this shows: The value of this constant is "<script>".
  public static final String SCRIPT_START = "<script>";
  /**
   * Evaluates the script starting with {@value TestClass#SCRIPT_START}.
   */
  // In Eclipse this shows: Evaluates the script starting with {@value TestClass#SCRIPT_START}.
  public void test1() {
  /**
   * Evaluates the script starting with {@value #SCRIPT_START}.
   */
  // In Eclipse this shows: Evaluates the script starting with "<script>".
  public void test2() {
  }
}

A bug已为此使用 Eclipse 创建。

关于java - 为什么 Eclipse 在另一个类中使用时不能处理 @value?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18832552/

相关文章:

java - 如何在类级别注释中为 JavaDocs 启用 Java checkstyle?

Javadoc 模板生成器

java - 为什么泛型父类(super class)型的 Java 类型推断会在这里中断?

java - 在java中获取一周的第一个日期

java - IntelliJ java.lang.ClassNotFoundException : com. mysql.jdbc.Driver - 连接到 XAMPP MySQL 数据库

java - Eclipse 调试器无法使用 'ssh' 或 'whoami' 等 shell 命令...为什么?

java - Eclipse 如何将包含 javadocs/source 的 jar 与其二进制文件链接?

java - 重写抽象方法 TimerTask.Run()

java - Eclipse 启动配置错误 : GrammaticalStructure. 1 引用不存在的项目开始

java - 构建Eclipse RCP应用程序,运行失败