Bug 537349 - Add warning if Javadoc @value doesn't reference constant value
Summary: Add warning if Javadoc @value doesn't reference constant value
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.8   Edit
Hardware: PC Mac OS X
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-24 14:08 EDT by Siegmar Alber CLA
Modified: 2020-05-06 11:08 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Siegmar Alber CLA 2018-07-24 14:08:25 EDT
Given the code

public class Test {
  /** {@value} */
  public static final String FOO = "foo";
  /** {@value} */
  public static final String BAR = bar();

  private static String bar() {
    return "bar";
  }
}

the first Javadoc renders correctly as "foo" and the second renders as expected as just "{@value}" (because the value assigned to BAR is not a constant expression in the sense of JLS §15.28[1]).


The feature request:

It would be nice if Eclipse issues a (optional) warning if a Javadoc @value tag does not (explicitly or implicitly) reference a constant variable (in the sense of JLS §4.12.4[2]). The result would always render as "{@value}", which is probably not intended most of the time.

[1] https://docs.oracle.com/javase/specs/jls/se10/html/jls-15.html#jls-15.28
[2] https://docs.oracle.com/javase/specs/jls/se10/html/jls-4.html#jls-4.12.4