RFR [8034044] Class.getModifiers() returns "static" for anonymous classes

Alex Buckley alex.buckley at oracle.com
Fri Mar 7 18:10:08 UTC 2014

On 3/7/2014 12:29 AM, Ivan Gerasimov wrote:
> JLS states that an anonymous class cannot be static [1].
> However, in OpenJDK implementation Class#getModifiers(), when called for
> the anonymous class, returns the STATIC bit set.
> Would you please help review the proposed fix, which removes STATIC from
> the anonymous class's modifier?
> An exception to this is an enum constant's body.
> It's not clear, whether they should be treated in the same way as
> anonymous classes, so I left them as they are now.

JLS 8.9.1: The optional class body of an enum constant implicitly 
defines an anonymous class declaration (§15.9.5) that extends the 
immediately enclosing enum type.

So the class generated for an enum constant's body should not be ACC_STATIC.


More information about the compiler-dev mailing list