Matthias Braun
Matthias Braun

Reputation: 34313

Why can't Eclipse handle @value when used in another class?

I want the string from A_CONSTANT to be part of the comments of 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 {

}

The {@value} in ClassA shows me the string content when hovering over the constant's name; that's fine.

Also the @see tag does its job in ClassB by linking to A_CONSTANT.

Yet the two {@value ...} attempts in ClassB fail: I see the literal {@value ...} part and not the contents of A_CONSTANT when hovering over ClassB.

The documentation tells me to use the following notation which I think I did: {@value package.class#field}.

The answer to this question also advises to use the above notation.

This is basically the same question as mine but was not answered.

How can I show the string contents of the constant in the comments of the other class?

I'm using Eclipse Juno on Windows 7 x86.

Thanks in advance.

Edit:

When running javadoc.exe on my project {@value my.stuff.ClassA#A_CONSTANT} resolves to the correct string.

This is why I have changed the question a bit:

Why doesn't Eclipse display the constant's string on mouseover while javadoc.exe has no problem with it?

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

Upvotes: 16

Views: 3299

Answers (2)

Paul Wagland
Paul Wagland

Reputation: 29116

This would appear to be a bug in Eclipse. Modifying the example slightly from 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 has been created with eclipse for this.

Upvotes: 10

Scott Woodward
Scott Woodward

Reputation: 325

On the javadoc reference page that you linked to here, under "Where Tags Can Be Used" it cites that @value can be used on a field, but not on a class. In Class B, the javadoc is on the class, which is invalid. Its possible that eclipse is strictly following that evaluation while the javadoc.exe is more lenient with placement.

Upvotes: -1

Related Questions