Anonymous classes are not final according to reflection API

Maurizio Cimadamore maurizio.cimadamore at
Fri Jul 3 14:17:34 UTC 2015

On 02/07/15 23:10, Dan Smith wrote:
> - The JLS assertion "An anonymous class is always implicitly final" is meaningless if it's not interpreted as "the ACC_FINAL flag on the generated class is set", so if we're not going to enforce that, the assertion should be dropped.  (The other assertions in 15.9.5 have language-level implications, but not this, since none of the corresponding language restrictions in could ever arise.)
unless the VM, javac, and JDK (reflection) agree on a standard form in 
which anonymous classes are encoded. It seems like reflection has an 
'isAnonymousClass' method, whose implementation does the following:

public booleanisAnonymousClass() {

So we already have a way to establish if a class is anonymous in the 
runtime. Which means we also have a way to infer correct finality 
without touching ACC_FINAL.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list