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

Print this page

        

@@ -2109,14 +2109,12 @@
                 //
                 //    E . new <typeargs1>C<typargs2>(args) ( class <empty-name> { ... } )  .
                 //
                 // This expression is then *transformed* as follows:
                 //
-                // (1) add a STATIC flag to the class definition
-                //     if the current environment is static
-                // (2) add an extends or implements clause
-                // (3) add a constructor.
+                // (1) add an extends or implements clause
+                // (2) add a constructor.
                 //
                 // For instance, if C is a class, and ET is the type of E,
                 // the expression
                 //
                 //    E.new <typeargs1>C<typargs2>(args) { ... }

@@ -2129,11 +2127,17 @@
                 //       <typarams> X(ET e, args) {
                 //         e.<typeargs1>super(args)
                 //       }
                 //       ...
                 //     }
-                if (Resolve.isStatic(env)) cdef.mods.flags |= STATIC;
+                //
+                // NOTE: STATIC flag used to be added to the class
+                //       definition in a static environment.
+                //       However, according to JLS: 15.9.5:
+                //       "An anonymous class is never static"
+                //       So, it is not added anymore.
+                //
 
                 if (clazztype.tsym.isInterface()) {
                     cdef.implementing = List.of(clazz);
                 } else {
                     cdef.extending = clazz;