Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8029376

Full attribution of unresolvable annotations

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 9
    • 7u11, 8
    • tools
    • b02
    • Verified

    Description

      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"

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: