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

javac wrongly rejects some class literals as annotation element values

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 9
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b117
    • Verification:
      Verified

      Description

      See the thread "references to non-static types from annotations" at http://mail.openjdk.java.net/pipermail/compiler-dev/2016-April/010104.html.

      In a nutshell, @A(I.class) in the source below is legal, but javac generates a invalid RuntimeVisibleAnnotations attribute for it. javac is effectively interpreting the annotation as @A(Test<T>.I.class) but should interpret it as @A(Test.I.class), which compiles correctly when written in source by hand.

      class Test<T> {
          @Retention(RetentionPolicy.RUNTIME) @interface A { Class<?> value(); }

          // A nested interface is static. The annotation refers to a non-static class.
          @A(I.class) interface C {}

          class I {}
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jjg Jonathan Gibbons
                Reporter:
                abuckley Alex Buckley
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: