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

javac should issue an error if an annotation is nested in a local class or interface

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b30
    • Verification:
      Verified

      Backports

        Description

        Please refer to below code:

        public class Test {
            public static void main(String[] args) {
                class LocalCls {
                    @interface TestAnnot {}
                }
            }
        }

        As per assertion "It is a compile-time error if an annotation declaration is nested within the body of a local class or interface declaration (14.3), or within the body of an anonymous class (15.9.5).", the above code should result in error. However, no compilation error is thrown.

        [1] http://cr.openjdk.java.net/~gbierman/8246771/8246771-20200928/specs/local-statics-jls.html , see section: "9.6 Annotation Interfaces"

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                vromero Vicente Arturo Romero Zaldivar
                Reporter:
                vkhatri Vinod Khatri
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: