Anonymous classes are not final according to reflection API
John Rose
john.r.rose at oracle.com
Tue Jul 7 03:42:04 UTC 2015
But that's a hack too. It breaks if the name computes to a null string. As opposed to the documented null CP ref.
– John
> On Jul 3, 2015, at 7:17 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>
>
>
>> 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 8.1.1.2 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 boolean isAnonymousClass() {
> return "".equals(getSimpleName());
> }
>
> 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.
>
> Maurizio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20150706/3740f2af/attachment.html>
More information about the compiler-dev
mailing list