Full attribution of unresolvable annotations

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 9
    • Affects Version/s: 7u11, 8
    • Component/s: tools
    • b02
    • Verified

      Consider this source code (intentionally missing imports):
      -----
      @Retention(RetentionPolicy.SOURCE)
      @interface Anno {
      }
      -----

      Currently, javac won't attribute the "@Retention"'s attributes. As a consequence, the only compile-time error produced is:
      -----
      Anno.java:1: error: cannot find symbol
      @Retention(RetentionPolicy.SOURCE)
       ^
        symbol: class Retention
      1 error
      -----

      Which may be inconvenient for the user - adding an import for "java.lang.annotation.Retention" and recompiling will lead to more compile-time errors:
      -----
      Anno.java:2: error: cannot find symbol
      @Retention(RetentionPolicy.SOURCE)
                 ^
        symbol: variable RetentionPolicy
      Anno.java:2: error: an enum annotation value must be an enum constant
      @Retention(RetentionPolicy.SOURCE)
                                ^
      2 errors
      -----

      It may be more convenient to mark both the Retention and RetentionPolicy as unresolvable in the first case, so that the user knows both need to be imported.

      Reproducible with:
      $ javac -fullversion
      javac full version "1.7.0_11-b21"

      and:
      $ javac -fullversion
      javac full version "1.8.0-ea-b117"

            Assignee:
            Jan Lahoda
            Reporter:
            Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: