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

deprecation warnings should be emitted for uses of annotation methods inside other annotations

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 21
    • 19
    • tools
    • None
    • b08

      My colleague Chris Povirk noticed that in the following example, javac emits deprecation warnings for method invocations that refer to the deprecated method A.b, but not for uses of that method in other annotations.

      Ideally it would report a diagnostic for both usages of the deprecated element.

      ```
      @interface A {
        @Deprecated
        /**
         * @deprecated foo
         */
        boolean b() default false;
      }
      ```

      ```
      @A(b = true)
      // ^
      // expected a deprecation warning on use of b above
      class B {
        void x(A a) {
          a.b();
        }
      }
      ```
      $ javac -fullversion
      javac full version "19-ea+34-2229"
      $ javac -deprecation *.java
      B.java:6: warning: [deprecation] b() in A has been deprecated
          a.b();
           ^
      1 warning

            vromero Vicente Arturo Romero Zaldivar
            cushon Liam Miller-Cushon
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: