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

access flags inside local class are allowed for source levels previous to 16

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • tools
    • None

      This code:

      public class Modifiers {
           private void test() {
               class L {
                   private class Test {}
               }
           }
      }

      is rejected by JDK15 javac compiler, but it is accepted if compiled with JDK 16 compiler with source level 15. There is no rule in the spec that restricts the modifiers of members of local classes. If we decide not to keep this non-specified javac behavior, then we can probably close this issue.

      Another variation of the same issue:

      public class ModifiersAnonymous {
           private Object o = new Object() {
               private class Test {}
           };
      }

      (reported offline by Jan)

            abimpoudis Angelos Bimpoudis
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: