Javadoc使用@value在内部类常量上显示值

eol*_*old 26 java annotations javadoc constants

我有一个内部类,它声明一个常量,并希望使用@value注释在封闭的顶级类的Javadoc中显示它的值.例如:

/**
 * {@value #FOO_CONS} // this displays well
 * {@value #BAR_CONS} // this does not work (checked in the latest Eclipse)
 * {@value Bar#BAR_CONS} // this does not work, either
 */
public Foo {
  public static final int FOO_CONS = 1;
  static class Bar {
    public static final int BAR_CONS = 42;
  }
}
Run Code Online (Sandbox Code Playgroud)

任何想法如何在Foo类(或任何其他类,一般)的Javadoc中显示BAR_CONS的值?

小智 11

另一个包中定义的常量的Javadoc格式应为:
{@ value package.class #field}

但是,它可能无法呈现是一个已知问题:https:
//bugs.eclipse.org/bugs/show_bug.cgi?id = 342194


use*_*612 2

如果为具有可见性“package”(这是 Bar 类的可见性)的成员创建 javadoc,我会在 Foo.Bar 下的 javadoc 中得到常量