Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 359
Matthias Braun Avatar asked Sep 16 '13 16:09

Matthias Braun


1 Answers

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.

like image 59
Paul Wagland Avatar answered Oct 14 '22 18:10

Paul Wagland