src/share/classes/com/sun/tools/javac/comp/Check.java

Print this page

        

@@ -1071,13 +1071,15 @@
             break;
         case TYP:
             if (sym.isLocal()) {
                 mask = LocalClassFlags;
                 if (sym.name.isEmpty()) { // Anonymous class
-                    // Anonymous classes in static methods are themselves static;
-                    // that's why we admit STATIC here.
+                    // JLS 15.9.5.: An anonymous class is never static,
+                    if ((flags & ENUM) != 0) {
+                        // extended ENUM is an exception
                     mask |= STATIC;
+                    }
                     // JLS: Anonymous classes are final.
                     implicit |= FINAL;
                 }
                 if ((sym.owner.flags_field & STATIC) == 0 &&
                     (flags & ENUM) != 0)