src/share/classes/com/sun/tools/javac/comp/Attr.java
Print this page
*** 2109,2122 ****
//
// 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.
//
// For instance, if C is a class, and ET is the type of E,
// the expression
//
// E.new <typeargs1>C<typargs2>(args) { ... }
--- 2109,2120 ----
//
// E . new <typeargs1>C<typargs2>(args) ( class <empty-name> { ... } ) .
//
// This expression is then *transformed* as follows:
//
! // (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,2139 ****
// <typarams> X(ET e, args) {
// e.<typeargs1>super(args)
// }
// ...
// }
! if (Resolve.isStatic(env)) cdef.mods.flags |= STATIC;
if (clazztype.tsym.isInterface()) {
cdef.implementing = List.of(clazz);
} else {
cdef.extending = clazz;
--- 2127,2143 ----
// <typarams> X(ET e, args) {
// e.<typeargs1>super(args)
// }
// ...
// }
! //
! // 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;