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

Annotation processor observes interface private methods as default methods

    Details

      Backports

        Description

        Let's consider interface below:

        interface MyIntf {
            private int foo(int x) { return x+1; }
        }

        When it's compiled and resulted class-file is processed by annotation processor the j.l.m.e.Element instance corresponding to the method foo has 'private' and 'default' modifiers as j.l.m.e.Element.getModifiers() method returns. This looks like a bug.

        The minimized testcase is attached in order to reproduce, please:
        1. Unzip attached archive to some directory on Unix/Linux machine, say A;
        2. Modify A/Test61/test.sh by setting JDK_HOME to your JDK root dir;
        3. Run A/Test61/test.sh;

        This results in following output:
        Enclosed element: foo(int) modifiers [private]
        Enclosed element: foo(int) modifiers [private, default]

        The first line corresponds to annotation processor running against source file.
        The second one corresponds to annotation processor running against class file.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  sadayapalam Srikanth Adayapalam
                  Reporter:
                  grakov Georgiy Rakov (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: