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

Incorrect attribution of annotations on fields in anonymous classes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 8
    • Component/s: tools
    • Subcomponent:
    • Verification:
      Verified

      Description

      When compiling the code below, the field 'data' has 2 RuntimeVisibleTypeAnnotations, while the field in the anonymous class, 'data2' has3 RuntimeVisibleTypeAnnotations.
      If there are 2 (such as @A @B data2) it has 6 (rather than 4). A complete test case is attached.
      The same is true for methods.

          class testclass {
              @C String data = "test";
              void mtest( testclass t){ }
              public void test() {
                  mtest( new testclass() {
                           @D String data2 = "test";
                      });
              }
          }

          @Retention(RUNTIME)
          @Target({TYPE_USE,FIELD})
          @interface C { }

          @Retention(RUNTIME)
          @Target({TYPE_USE,FIELD})
          @interface D { }

        Attachments

          Activity

            People

            • Assignee:
              ssides Steve Sides
              Reporter:
              ssides Steve Sides
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: