Nested classes in local interfaces

Tagir Valeev amaembo at gmail.com
Mon Jun 15 11:54:23 UTC 2020


Hello!

I see the problems declaring nested classes inside the local
interfaces while it seems that it should be allowed by spec. Consider
the following code:

class Nested {
  void m() {
    interface I {
      static class C {}
    }
    new I.C();
  }
}

To me, this code should be compilable. Using javac 15-ea+26-1287, I
see the following error messages:

Nested.java:4: error: static declarations not allowed in inner classes
      static class C {}
             ^
Nested.java:6: error: C is not public in I; cannot be accessed from
outside package
    new I.C();
         ^
2 errors

With best regards,
Tagir Valeev.


More information about the amber-dev mailing list